Open Bug 1680402 Opened 2 months ago Updated 4 days ago

Make printf_stderr work on Windows when it's been redirected

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

REOPENED

People

(Reporter: jrmuizel, Assigned: jrmuizel, NeedInfo)

References

Details

Attachments

(1 file)

No description provided.

Currently, printf_stderr doesn't show up when running with ./mach run.
This is because we run with -attach-console and that redirects stderr
to a different file descriptor using freopen in UseParentConsole.

The change from just using stderr directly happened in bug 340443 and was done
to avoid some linking issues. That problem doesn't seem to apply anymore so we
should be able to go back to the straightforward implemention that works even
if stderr has been redirected.

Assignee: nobody → jmuizelaar
Status: NEW → ASSIGNED
Pushed by jmuizelaar@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/975163dad54f
Use stderr in printf_stderr instead of reopening fd 2. r=glandium

Looks like the intermingling of stdout and stderr confuses some harnesses.

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:jrmuizel, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(jmuizelaar)

Masatoshi, it doesn't look like we fflush(stderr) on the other platforms. Do we need to on Windows?

Flags: needinfo?(VYV03354)

Here's a version that instead of writing directly to stderr replaces _fdopen(_dup(2), "a"); with _fdopen(_dup(_fileno(stderr)), "a");

https://treeherder.mozilla.org/jobs?repo=try&revision=e90bcf1adc9d8d6795dc95cc95c4aa115cf3e8fd&selectedTaskRun=T9urhs3MT3CDerURj0yMYw.0

It avoids the problems of the earlier version. But I don't really understand why yet.

Flags: needinfo?(jmuizelaar)

Ok, my theory for the reason this works is because when reopen with a new FILE* we get the default buffering instead of stderr's no buffering.

Pushed by jmuizelaar@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a4bf5887fc2a
Use stderr in printf_stderr instead of reopening fd 2. r=glandium
Status: ASSIGNED → RESOLVED
Closed: 5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
Regressions: 1686387

Backed out changeset a4bf5887fc2a (Bug 1680402) for being the most likely cause of Bug 1686387.
https://hg.mozilla.org/mozilla-central/rev/9594d105ec370e1512c20b23e9e523262ebcc4ca

Status: RESOLVED → REOPENED
Flags: needinfo?(jmuizelaar)
Resolution: FIXED → ---
Target Milestone: 86 Branch → ---
You need to log in before you can comment on or make changes to this bug.