<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>236807</bug_id>
          
          <creation_ts>2022-02-17 15:26:57 -0800</creation_ts>
          <short_desc>[DataLog] Disable buffering of output only for file, not stderr</short_desc>
          <delta_ts>2022-02-25 17:25:31 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>ASSIGNED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Basuke Suzuki">basuke</reporter>
          <assigned_to name="Basuke Suzuki">basuke</assigned_to>
          <cc>aakash_jain</cc>
    
    <cc>achristensen</cc>
    
    <cc>basuke</cc>
    
    <cc>benjamin</cc>
    
    <cc>cdumez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>darin</cc>
    
    <cc>don.olmstead</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>fujii</cc>
    
    <cc>msaboff</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1843148</commentid>
    <comment_count>0</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2022-02-17 15:26:57 -0800</bug_when>
    <thetext>Stderr is usually unbuffered. This requires only for file.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1843154</commentid>
    <comment_count>1</comment_count>
      <attachid>452440</attachid>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2022-02-17 15:32:56 -0800</bug_when>
    <thetext>Created attachment 452440
PATCH</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1843389</commentid>
    <comment_count>2</comment_count>
    <who name="Aakash Jain">aakash_jain</who>
    <bug_when>2022-02-18 07:18:08 -0800</bug_when>
    <thetext>I cancelled https://ews-build.webkit.org/#/builders/68/builds/8529 to speed up ios-wk2 queue. It already finished running layout-tests and the failures seems to be pre-existing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1844472</commentid>
    <comment_count>3</comment_count>
      <attachid>452440</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2022-02-21 17:32:58 -0800</bug_when>
    <thetext>Comment on attachment 452440
PATCH

View in context: https://bugs.webkit.org/attachment.cgi?id=452440&amp;action=review

&gt; Source/WTF/ChangeLog:8
&gt; +        `stderr` is usually already unbuffered. Disabling buffering is required only for file.

I have two questions :)

1. Is it guaranteed that `stderr` is unbuffered? (e.g. specified in C spec etc.).
2. What is the benefit of doing this only for file? If (1) is not guaranteed, always calling setvbuf sounds safer option to me, so I would like to know the motivation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1844477</commentid>
    <comment_count>4</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2022-02-21 17:39:37 -0800</bug_when>
    <thetext>(In reply to Yusuke Suzuki from comment #3)
&gt; Comment on attachment 452440 [details]
&gt; PATCH
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=452440&amp;action=review
&gt; 
&gt; &gt; Source/WTF/ChangeLog:8
&gt; &gt; +        `stderr` is usually already unbuffered. Disabling buffering is required only for file.
&gt; 
&gt; I have two questions :)
&gt; 
&gt; 1. Is it guaranteed that `stderr` is unbuffered? (e.g. specified in C spec
&gt; etc.).
&gt; 2. What is the benefit of doing this only for file? If (1) is not
&gt; guaranteed, always calling setvbuf sounds safer option to me, so I would
&gt; like to know the motivation.

1. I use the word &quot;usually&quot; casually without doing a wide research, but as far as I do quick googling, Linux, FreeBSD do disabling buffering by default. If not so, there might be the reason not to do that. stderr is something provided from the system so that it is better to use it as is.

2. Above is the motivation. Not changing the system&apos;s expectation is the benefit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1844488</commentid>
    <comment_count>5</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2022-02-21 18:07:21 -0800</bug_when>
    <thetext>I&apos;ll do this by wrapping with PLATFORM macro.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1844787</commentid>
    <comment_count>6</comment_count>
      <attachid>452440</attachid>
    <who name="Don Olmstead">don.olmstead</who>
    <bug_when>2022-02-22 10:43:33 -0800</bug_when>
    <thetext>Comment on attachment 452440
PATCH

View in context: https://bugs.webkit.org/attachment.cgi?id=452440&amp;action=review

&gt;&gt;&gt; Source/WTF/ChangeLog:8
&gt;&gt;&gt; +        `stderr` is usually already unbuffered. Disabling buffering is required only for file.
&gt;&gt; 
&gt;&gt; I have two questions :)
&gt;&gt; 
&gt;&gt; 1. Is it guaranteed that `stderr` is unbuffered? (e.g. specified in C spec etc.).
&gt;&gt; 2. What is the benefit of doing this only for file? If (1) is not guaranteed, always calling setvbuf sounds safer option to me, so I would like to know the motivation.
&gt; 
&gt; 1. I use the word &quot;usually&quot; casually without doing a wide research, but as far as I do quick googling, Linux, FreeBSD do disabling buffering by default. If not so, there might be the reason not to do that. stderr is something provided from the system so that it is better to use it as is.
&gt; 
&gt; 2. Above is the motivation. Not changing the system&apos;s expectation is the benefit.

The C standard says in 7.21.3 Files (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf)

At program startup, three text streams are predefined and need not be opened explicitly — standard
input (for reading conventional input), standard output (for writing conventional output), and standard
error (for writing diagnostic output). As initially opened, the standard error stream is not fully
buffered; the standard input and standard output streams are fully buffered if and only if the stream
can be determined not to refer to an interactive device.

You should definitely put more information in the CHANGELOG here rather than just a &quot;usually&quot;. Looking at documentation does seem to provide a clear case that it is unbuffered on Linux and FreeBSD but I don&apos;t know if that&apos;s the case with Apple OS&apos;s. Windows does seem like it might be buffered https://docs.microsoft.com/en-us/cpp/c-runtime-library/stream-i-o?view=msvc-170 so some kind of platform check is probably needed for this change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1844797</commentid>
    <comment_count>7</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2022-02-22 11:05:37 -0800</bug_when>
    <thetext>Thanks. Platform dependent macro sounds reasonable for this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1844822</commentid>
    <comment_count>8</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2022-02-22 12:09:08 -0800</bug_when>
    <thetext>In the spec:

&gt; The setvbuf function may be used only after the stream pointed to by stream has been associated
&gt; with an open file and before any other operation (other than an unsuccessful call to setvbuf) is
&gt; performed on the stream. 

It seems too late to change stderr here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1844910</commentid>
    <comment_count>9</comment_count>
      <attachid>452440</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-02-22 15:37:15 -0800</bug_when>
    <thetext>Comment on attachment 452440
PATCH

I think the patch is correct just like this and does not require platform conditionals.

I think it’s clear now that it’s an error to call setvbuf on stderr this late in the execution of a program, based on documentation of the cross platform standards that both setvbuf and stderr are part of. There is a highly-unlikely possibility that doing this to stderr is valuable on Apple platforms; someone should determine quickly, by testing, that this is not the case. Then we can land this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1845365</commentid>
    <comment_count>10</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-02-23 15:39:42 -0800</bug_when>
    <thetext>&lt;rdar://problem/89382520&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1846249</commentid>
    <comment_count>11</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2022-02-25 17:25:31 -0800</bug_when>
    <thetext>&gt; I think it’s clear now that it’s an error to call setvbuf on stderr this
&gt; late in the execution of a program, based on documentation of the cross
&gt; platform standards that both setvbuf and stderr are part of. There is a
&gt; highly-unlikely possibility that doing this to stderr is valuable on Apple
&gt; platforms; someone should determine quickly, by testing, that this is not
&gt; the case. Then we can land this.

Thanks Darin. Can somebody in Apple do this test? I want to add description about the effect to Apple platform.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>452440</attachid>
            <date>2022-02-17 15:32:56 -0800</date>
            <delta_ts>2022-02-23 05:25:15 -0800</delta_ts>
            <desc>PATCH</desc>
            <filename>patch.diff</filename>
            <type>text/plain</type>
            <size>1690</size>
            <attacher name="Basuke Suzuki">basuke</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nIGIvU291cmNlL1dURi9DaGFuZ2VMb2cK
aW5kZXggM2UyYzgwNTZmMDJhLi4yOTIxOTZmN2RlNzYgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYv
Q2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTUgQEAKKzIw
MjItMDItMTcgIEJhc3VrZSBTdXp1a2kgIDxiYXN1a2Uuc3V6dWtpQHNvbnkuY29tPgorCisgICAg
ICAgIFtEYXRhTG9nXSBEaXNhYmxlIGJ1ZmZlcmluZyBvZiBvdXRwdXQgb25seSBmb3IgZmlsZSwg
bm90IHN0ZGVycgorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/
aWQ9MjM2ODA3CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAg
ICAgYHN0ZGVycmAgaXMgdXN1YWxseSBhbH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Jhc2ggb3IgZGVhZGxvY2suCisgICAgICAg
IH0gZWxzZQogICAgICAgICAgICAgV1RGTG9nQWx3YXlzKCJXYXJuaW5nOiBDb3VsZCBub3Qgb3Bl
biBEYXRhTG9nIGZpbGUgJXMgZm9yIHdyaXRpbmcuXG4iLCBwYXRoVG9PcGVuKTsKICAgICB9CiAK
QEAgLTE1MCw4ICsxNTIsNiBAQCB2b2lkIHNldERhdGFGaWxlKGNvbnN0IGNoYXIqIHBhdGgpCiAg
ICAgICAgIGZpbGUgPSBuZXcgKHNfZmlsZURhdGEpIEZpbGVQcmludFN0cmVhbShzdGRlcnIsIEZp
bGVQcmludFN0cmVhbTo6Qm9ycm93KTsKICAgICB9CiAKLSAgICBzZXR2YnVmKGZpbGUtPmZpbGUo
KSwgbnVsbHB0ciwgX0lPTkJGLCAwKTsgLy8gUHJlZmVyIHVuYnVmZmVyZWQgb3V0cHV0LCBzbyB0
aGF0IHdlIGdldCBhIGZ1bGwgbG9nIHVwb24gY3Jhc2ggb3IgZGVhZGxvY2suCi0KICAgICBpZiAo
c19maWxlKQogICAgICAgICBzX2ZpbGUtPmZsdXNoKCk7CiANCg==
</data>
<flag name="commit-queue"
          id="480173"
          type_id="3"
          status="-"
          setter="ews-feeder"
    />
          </attachment>
      

    </bug>

</bugzilla>