Bug #69031 [Asn]: Long messages into stdout/stderr are truncated incorrectly

From: Date: Sat, 07 Jul 2018 12:19:47 +0000
Subject: Bug #69031 [Asn]: Long messages into stdout/stderr are truncated incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216200@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69031&edit=1

 ID:                 69031
 Updated by:         bukka@php.net
 Reported by:        dz at heroku dot com
 Summary:            Long messages into stdout/stderr are truncated
                     incorrectly
 Status:             Assigned
 Type:               Bug
 Package:            FPM related
 Operating System:   irrelevant
 PHP Version:        5.6.5
 Assigned To:        bukka
 Block user comment: N
 Private report:     N

 New Comment:

The main fix merged in https://github.com/php/php-src/commit/3e5afbf0a80317216d98c6e5c0dd2eb54f34e438

I will keep this open as a reminder for a bug with very high limit as noted in https://github.com/php/php-src/pull/2458#issuecomment-402552120


Previous Comments:
------------------------------------------------------------------------
[2017-04-10 18:58:06] bukka@php.net

I'm working on it in https://github.com/php/php-src/pull/2458

------------------------------------------------------------------------
[2015-02-19 13:57:09] jpauli@php.net

Ping @remi as he has good knowledge of FPM

------------------------------------------------------------------------
[2015-02-11 15:36:42] dz at heroku dot com

Description:
------------
The maximum zlog message length is 1024 including timestamp et cetera.

With very long messages over 1024 characters, these get wrapped into multiple chunks correctly, but
then the "WARNING: child blah said into blah" gets added and the zlog call truncates the
messages using "..." at the end, resulting in a couple dozen bytes getting lost.

This change calculates the length at which wrapping needs to occur correctly.

To reproduce, long a long message to stderr, e.g. a bit of Shakespeare:

Test script:
---------------
file_put_contents('php://stderr', "If it were done when 'tis done, then
'twere well // It were done quickly. If the assassination // Could trammel up the consequence,
and catch, // With his surcease, success; that but this blow // Might be the be-all and the
end-all--here, // But here, upon this bank and shoal of time,-- // We'd jump the life to come.
But in these cases // We still have judgement here; that we but teach // Bloody instructions, which
being taught, return // To plague the inventor: this even-handed justice // Commends the ingredients
of our poison'd chalice // To our own lips. He's here in double trust: // First, as I am
his kinsman and his subject, // Strong both against the deed: then, as his host, // Who should
against his murderer shut the door, // Not bear the knife myself. Besides, this Duncan // Hath borne
his faculties so meek, hath been // So clear in his great office, that his virtues // Will plead
like angels, trumpet-tongued, against // The deep da!
 mnation of his taking-off: // And pity, like a naked new-born babe, // Striding the blast, or
heaven's cherubin, hors'd // Upon the sightless couriers of the air, // Shall blow the
horrid deed in every eye, // That tears shall drown the wind.--I have no spur // To prick the sides
of my intent, but only // Vaulting ambition, which o'erleaps itself, // And falls on the other.
// Is this a dagger which I see before me, // The handle toward my hand? Come, let me clutch thee:--
// I have thee not, and yet I see thee still. // Art thou not, fatal vision, sensible // To feeling
as to sight? or art thou but // A dagger of the mind, a false creation, // Proceeding from the
heat-oppressed brain? // I see thee yet, in form as palpable // As this which now I draw. // Thou
marshall'st me the way that I was going; // And such an instrument I was to use. // Mine eyes
are made the fools o' the other senses, // Or else worth all the rest: I see thee still; // And
on thy blade and dudgeon go!
 uts of blood, // Which was not so before.--There's no such thi!
 ng: // It is the bloody business which informs // Thus to mine eyes.--Now o'er the one
half-world // Nature seems dead, and wicked dreams abuse // The curtain'd sleep; now witchcraft
celebrates // Pale Hecate's offerings; and wither'd murder, // Alarum'd by his
sentinel, the wolf, // Whose howl's his watch, thus with his stealthy pace, // With
Tarquin's ravishing strides, towards his design // Moves like a ghost.--Thou sure and firm-set
earth, // Hear not my steps, which way they walk, for fear // Thy very stones prate of my
whereabout, // And take the present horror from the time, // Which now suits with it.--Whiles I
threat, he lives; // Words to the heat of deeds too cold breath gives. // ");


Expected result:
----------------
[11-Feb-2015 16:25:30] WARNING: [pool www] child 15441 said into stderr: "If it were done when
'tis done, then 'twere well // It were done quickly. If the assassination // Could trammel
up the consequence, and catch, // With his surcease, success; that but this blow // Might be the
be-all and the end-all--here, // But here, upon this bank and shoal of time,-- // We'd jump the
life to come. But in these cases // We still have judgement here; that we but teach // Bloody
instructions, which being taught, return // To plague the inventor: this even-handed justice //
Commends the ingredients of our poison'd chalice // To our own lips. He's here in double
trust: // First, as I am his kinsman and his subject, // Strong both against the deed: then, as his
host, // Who should against his murderer shut the door, // Not bear the knife myself. Besides, this
Duncan // Hath borne his faculties so meek, hath been // So clear in his great office, that his
virtues // Will plead like angels, !
 trumpet-tongued, against // The d"
[11-Feb-2015 16:25:30] WARNING: [pool www] child 15441 said into stderr: "eep damnation of his
taking-off: // And pity, like a naked new-born babe, // Striding the blast, or heaven's
cherubin, hors'd // Upon the sightless couriers of the air, // Shall blow the horrid deed in
every eye, // That tears shall drown the wind.--I have no spur // To prick the sides of my intent,
but only // Vaulting ambition, which o'erleaps itself, // And falls on the other. // Is this a
dagger which I see before me, // The handle toward my hand? Come, let me clutch thee:-- // I have
thee not, and yet I see thee still. // Art thou not, fatal vision, sensible // To feeling as to
sight? or art thou but // A dagger of the mind, a false creation, // Proceeding from the
heat-oppressed brain? // I see thee yet, in form as palpable // As this which now I draw. // Thou
marshall'st me the way that I was going; // And such an instrument I was to use. // Mine eyes
are made the fools o' the other senses, // O!
 r else worth all the rest: I see "
[11-Feb-2015 16:25:30] WARNING: [pool www] child 15441 said into stderr: "thee still; // And on
thy blade and dudgeon gouts of blood, // Which was not so before.--There's no such thing: // It
is the bloody business which informs // Thus to mine eyes.--Now o'er the one half-world //
Nature seems dead, and wicked dreams abuse // The curtain'd sleep; now witchcraft celebrates //
Pale Hecate's offerings; and wither'd murder, // Alarum'd by his sentinel, the wolf,
// Whose howl's his watch, thus with his stealthy pace, // With Tarquin's ravishing
strides, towards his design // Moves like a ghost.--Thou sure and firm-set earth, // Hear not my
steps, which way they walk, for fear // Thy very stones prate of my whereabout, // And take the
present horror from the time, // Which now suits with it.--Whiles I threat, he lives; // Words to
the heat of deeds too cold breath gives. // "

Actual result:
--------------
[11-Feb-2015 16:35:20] WARNING: [pool www] child 27103 said into stderr: "If it were done when
'tis done, then 'twere well // It were done quickly. If the assassination // Could trammel
up the consequence, and catch, // With his surcease, success; that but this blow // Might be the
be-all and the end-all--here, // But here, upon this bank and shoal of time,-- // We'd jump the
life to come. But in these cases // We still have judgement here; that we but teach // Bloody
instructions, which being taught, return // To plague the inventor: this even-handed justice //
Commends the ingredients of our poison'd chalice // To our own lips. He's here in double
trust: // First, as I am his kinsman and his subject, // Strong both against the deed: then, as his
host, // Who should against his murderer shut the door, // Not bear the knife myself. Besides, this
Duncan // Hath borne his faculties so meek, hath been // So clear in his great office, that his
virtues // Will plead like angels, !
 trumpet-tongued, against // The...
[11-Feb-2015 16:35:20] WARNING: [pool www] child 27103 said into stderr: "/ Striding the blast,
or heaven's cherubin, hors'd // Upon the sightless couriers of the air, // Shall blow the
horrid deed in every eye, // That tears shall drown the wind.--I have no spur // To prick the sides
of my intent, but only // Vaulting ambition, which o'erleaps itself, // And falls on the other.
// Is this a dagger which I see before me, // The handle toward my hand? Come, let me clutch thee:--
// I have thee not, and yet I see thee still. // Art thou not, fatal vision, sensible // To feeling
as to sight? or art thou but // A dagger of the mind, a false creation, // Proceeding from the
heat-oppressed brain? // I see thee yet, in form as palpable // As this which now I draw. // Thou
marshall'st me the way that I was going; // And such an instrument I was to use. // Mine eyes
are made the fools o' the other senses, // Or else worth all the rest: I see thee still; // And
on thy blade and dudgeo!
 n gouts of blood, // Which was ...
[11-Feb-2015 16:35:20] WARNING: [pool www] child 27103 said into stderr: "orms // Thus to mine
eyes.--Now o'er the one half-world // Nature seems dead, and wicked dreams abuse // The
curtain'd sleep; now witchcraft celebrates // Pale Hecate's offerings; and wither'd
murder, // Alarum'd by his sentinel, the wolf, // Whose howl's his watch, thus with his
stealthy pace, // With Tarquin's ravishing strides, towards his design // Moves like a
ghost.--Thou sure and firm-set earth, // Hear not my steps, which way they walk, for fear // Thy
very stones prate of my whereabout, // And take the present horror from the time, // Which now suits
with it.--Whiles I threat, he lives; // Words to the heat of deeds too cold breath gives. // "


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69031&edit=1


Thread (4 messages)

« previous php.bugs (#216200) next »