Opened 14 years ago

Closed 14 years ago

#58 closed defect (fixed)

libc: closed standard handles cause uninitialized stdout/stdin/stderr streams

Reported by: bird Owned by: bird
Priority: high Milestone: libc-0.6.1
Component: baselayout Version: 0.6
Severity: major Keywords: libc stdout stdin stderr fclose fflush


smoketests/fclose-1.c exhibit a problem where the parent closes one or more of the standard handles before spawning a child or execing. The child will then end up with an the stream for those handles uninitialized, and any attempt to use them will panic libc.

Change History (2)

comment:1 Changed 14 years ago by bird

fclose-2 is a better testcase. It also shows that fclose() isn't returning the correct error code.

comment:2 Changed 14 years ago by bird

Resolution: fixed
Status: newclosed

The stdin/stdout/stderr streams should apparently always be initialized as opened. GLIBC will perform one failing fclose, and the subseqent ones failing because the stream is closed. BSD will fail in the same way all the way. This is in a child which was created with a closed, let say stdout.

If you do fclose(stdout) twice, BSD will crash, while GLIBC & LIBC will fail because it's already closed (no errno) as for 2+ fclose above.

(This problem was found with the coreutils tests/misc testcases.)

Note: See TracTickets for help on using tickets.