public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/30510] New: Program calling exit() with active threads produces wrong output
@ 2023-06-04 21:30 ppluzhnikov at google dot com
  2023-06-04 21:57 ` [Bug stdio/30510] " schwab@linux-m68k.org
  2023-06-04 22:16 ` ppluzhnikov at google dot com
  0 siblings, 2 replies; 3+ messages in thread
From: ppluzhnikov at google dot com @ 2023-06-04 21:30 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30510

            Bug ID: 30510
           Summary: Program calling exit() with active threads produces
                    wrong output
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: ppluzhnikov at google dot com
  Target Milestone: ---

https://stackoverflow.com/a/76399940

I would expect the following program to never produce duplicate numbers:

#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

void *func (void *p)
{
  size_t count = 0;
  while (1)
    printf ("%zu\n", ++count);

  return NULL;
}

int main (void)
{
  pthread_t tid;
  pthread_create (&tid, NULL, func, NULL);
  usleep (1000);
  return 0;
}


But running it against ToT produces:
1
2
...
260
261
262
263
264
265
266
267
267   <<<--- bug
268
269
270
270   <<<--- bug
271

This appears to stem from commit 64f01020838

commit 64f01020838a382d833254297f650d4a55933bde
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Mon Feb 9 20:08:44 2004 +0000

    (_IO_cleanup): Do not use locking when flushing the buffers.  Some thread
might be using a stream.


Not sure what the motivation was -- surely delaying exit a bit for sake of
correctness would be more appropriate here?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug stdio/30510] Program calling exit() with active threads produces wrong output
  2023-06-04 21:30 [Bug stdio/30510] New: Program calling exit() with active threads produces wrong output ppluzhnikov at google dot com
@ 2023-06-04 21:57 ` schwab@linux-m68k.org
  2023-06-04 22:16 ` ppluzhnikov at google dot com
  1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2023-06-04 21:57 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30510

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
See bug 15142 and bug 14697.

https://patchwork.sourceware.org/project/glibc/patch/mvmedyihcep.fsf@suse.de/

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug stdio/30510] Program calling exit() with active threads produces wrong output
  2023-06-04 21:30 [Bug stdio/30510] New: Program calling exit() with active threads produces wrong output ppluzhnikov at google dot com
  2023-06-04 21:57 ` [Bug stdio/30510] " schwab@linux-m68k.org
@ 2023-06-04 22:16 ` ppluzhnikov at google dot com
  1 sibling, 0 replies; 3+ messages in thread
From: ppluzhnikov at google dot com @ 2023-06-04 22:16 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30510

Paul Pluzhnikov <ppluzhnikov at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #2 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
Seems like BZ 15142 is the closest to this. Closing as dup.

*** This bug has been marked as a duplicate of bug 15142 ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-04 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-04 21:30 [Bug stdio/30510] New: Program calling exit() with active threads produces wrong output ppluzhnikov at google dot com
2023-06-04 21:57 ` [Bug stdio/30510] " schwab@linux-m68k.org
2023-06-04 22:16 ` ppluzhnikov at google dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).