Opened 11 years ago

Closed 10 years ago

#266 closed defect (fixed)

stderr is not thread safe

Reported by: James Moe Owned by: bird
Priority: Feedback Pending Milestone:
Component: libc Version:
Severity: normal Keywords: stderr thread
Cc:

Description

gcc v3.3.5 csd5 libc065

If multiple streams are sent to stderr (error output), it is possible for the output to become scrambled. In the example below the strings were sent to stderr after acquiring a mutex to prevent, well, what happened. The same thing happens with C++ and cerr.

20130131-15:44:15.077 (001)-C-pmmail_main_queue: step 1 20130131-15:44:15.077 (001)-I-ProgressCreateWindow?: n_opens [1]

2200113300113311--1155::4444:1:51.51.4184 8(0(00801))--II--sMpaeilnlWeirn_Cirneiatt:e Waisnp

The first two lines are how most of the log entries are printed. The

third line is a stuttering combination of two log lines.

Change History (1)

comment:1 Changed 10 years ago by bird

Priority: highestFeedback Pending
Resolution: fixed
Severity: majornormal
Status: newclosed

I don't quite understand your problem here. Within an application, stderr (as will all streams) be locked. The output you describe can easily be produced by multiple threads doing char-by-char fputc (or similar) to stderr or by using cerr. If you are talking about multiple processes, well, mixups must be expected.

Note: See TracTickets for help on using tickets.