Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/tsan/getline_nohang.cpp hangs with #1733

Open
vitalybuka opened this issue Mar 13, 2024 · 7 comments
Open

test/tsan/getline_nohang.cpp hangs with #1733

vitalybuka opened this issue Mar 13, 2024 · 7 comments

Comments

@vitalybuka
Copy link
Contributor

The test is for #454

Thread 3 (Thread 0x7f10133fe6c0 (LWP 3379986) "getline_nohang."):
#0  0x00007f101691a7dc in __GI___libc_read (nbytes=4096, buf=0x728000000000, fd=3) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=3, buf=0x728000000000, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007f101688dde3 in _IO_new_file_underflow (fp=0x725000000000) at ./libio/libioP.h:1030
#3  0x00007f10168828f0 in __GI___getdelim (lineptr=0x7f10133fd698, n=0x7f10133fd6a8, delimiter=10, fp=0x725000000000) at ./libio/iogetdelim.c:77
#4  0x0000555ca901138f in ___interceptor___getdelim () at /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/tsan/rtl/../../sanitizer_common/sanitizer_common_interceptors.inc:5350
#5  0x0000555ca90698a3 in getline () at /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include/bits/stdio.h:120
#6  thread () at /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/getline_nohang.cpp:24
#7  0x0000555ca8fe5d33 in __tsan_thread_start_func () at /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1012
#8  0x00007f1016897b5a in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:444
#9  0x00007f10169285fc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 2 (Thread 0x7f1013bff6c0 (LWP 3379985) "getline_nohang."):
#0  internal_usleep () at /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:508
#1  0x0000555ca904f5cf in BackgroundThread () at /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:473
#2  0x00007f1016897b5a in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:444
#3  0x00007f10169285fc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Thread 1 (Thread 0x7f1016efcf00 (LWP 3379984) "getline_nohang."):
#0  futex_wait (private=0, expected=2, futex_word=0x7250000000e0) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait_private (futex=0x7250000000e0) at ./nptl/lowlevellock.c:34
#2  0x00007f1016891875 in __GI__IO_flush_all () at ./libio/genops.c:698
#3  0x00007f1016891c4a in _IO_cleanup () at ./libio/genops.c:843
#4  0x00007f10168452a0 in __run_exit_handlers (status=0, listp=0x7f10169fe860 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at ./stdlib/exit.c:132
#5  0x00007f10168452e0 in __GI_exit (status=<optimized out>) at ./stdlib/exit.c:141
#6  0x00007f1016828157 in __libc_start_call_main (main=main@entry=0x555ca90698e0 <main>, argc=argc@entry=18, argv=argv@entry=0x7ffdfccb6408) at ../sysdeps/nptl/libc_start_call_main.h:74
#7  0x00007f1016828209 in __libc_start_main_impl (main=0x555ca90698e0 <main>, argc=18, argv=0x7ffdfccb6408, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffdfccb63f8) at ../csu/libc-start.c:360
#8  0x0000555ca8ea8ff5 in _start ()
@vitalybuka
Copy link
Contributor Author

This happens after upgrade to glibc 2.38

@vitalybuka
Copy link
Contributor Author

Does this look familiar @ramosian-glider @dvyukov ?

@vitalybuka
Copy link
Contributor Author

git log glibc-2.37...glibc-2.38 -- /usr/local/google/home/vitalybuka/src/glibc/libio/genops.c

commit bminor/glibc@af130d2
Author: Andreas Schwab schwab@suse.de
Date: Tue Jan 30 10:16:00 2018 +0100

Always do locking when accessing streams (bug 15142, bug 14697)

Now that abort no longer calls fflush there is no reason to avoid locking
the stdio streams anywhere.  This fixes a conformance issue and potential
heap corruption during exit.

commit bminor/glibc@8867734
Author: Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Date: Tue Dec 27 18:11:42 2022 -0300

Move libc_freeres_ptrs and libc_subfreeres to hidden/weak functions

They are both used by __libc_freeres to free all library malloc
allocated resources to help tooling like mtrace or valgrind with
memory leak tracking.

The current scheme uses assembly markers and linker script entries
to consolidate the free routine function pointers in the RELRO segment
and to be freed buffers in BSS.

This patch changes it to use specific free functions for
libc_freeres_ptrs buffers and call the function pointer array directly
with call_function_static_weak.

It allows the removal of both the internal macros and the linker
script sections.

Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

@vitalybuka
Copy link
Contributor Author

Probably bminor/glibc@af130d2

@vitalybuka
Copy link
Contributor Author

I believe the test is invalid after this changes.

vitalybuka added a commit to llvm/llvm-project that referenced this issue Mar 13, 2024
@dvyukov
Copy link
Contributor

dvyukov commented Mar 13, 2024

It hangs w/o tsan as well, right?

Does this mean a program generally cannot exit if any of the threads/libraries doing blocking stream calls (e.g. reading from stdio)? This looks restrictive.

Asked in the issue: https://sourceware.org/bugzilla/show_bug.cgi?id=15142

@vitalybuka
Copy link
Contributor Author

It hangs w/o tsan as well, right?

Does this mean a program generally cannot exit if any of the threads/libraries doing blocking stream calls (e.g. reading from stdio)? This looks restrictive.

Asked in the issue: https://sourceware.org/bugzilla/show_bug.cgi?id=15142

Actually it does not hang without tsan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants