-
Notifications
You must be signed in to change notification settings - Fork 36
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
testcase do not exit when run ‘malloc1_threads’ #33
Comments
Hi, I've just hit this same issue running on an Ampere Altra (arm64) system. It is pretty easy to reproduce. Looking at the backtraces, I think we have a deadlock caused by asynchronous cancellation of the threads. If the thread being cancelled is inside malloc() at the time of cancellation, it dies while holding the lock. Then during thread shutdown, free gets called and deadlocks waiting for the lock that will never be freed. Then the parent thread just waits in pthread_join() forever. I think you just not bother cleaning up the threads in the threaded case, and just exit the process. That might be a problem for testcase_cleanup() though if the the test case is potentially still running concurrently? Thanks, Thread back traces: (gdb) thread apply all bt Thread 3 (Thread 0xfffff4e6f100 (LWP 7068) "malloc1_threads" (Exiting)): Thread 2 (Thread 0xfffff567f100 (LWP 7067) "malloc1_threads" (Exiting)): Thread 1 (Thread 0xfffff7ff5440 (LWP 7066) "malloc1_threads"): |
It's a big old hack, but I've solved the problem by cancelling but not joining the child threads. This means that the child threads should not be running by the time we call testcase_cleanup() in the parent thread. And if the child thread gets deadlocked during cancellation, it will all be cleaned up when the process exits. For good measure, I've also removed this code from the main thread (we don't want it to deadlock on the same heap lock):
There are a few cases where testcase_cleanup() calls free(), but that only happens for test cases that make direct syscalls, so there should be no risk of deadlock here. Like I said, massive hack. But it unblocks me and shouldn't impact the results. |
See issue (antonblanchard#33). Since async pthread_cancel on threads that do hold locks is wrong, we instead create a separate process that holds the threads. On exit, the holding process just exits, and the parent wait()'s for it, and cleans up the testcase. Signed-off-by: Pedro Falcato <[email protected]>
Hi
'malloc1_threads' is not exit when run end.
stopped and not exit after put "average:12343"
will-it-scale# ./malloc1_threads -t 2 -s 1
testcase:malloc/free of 128MB
warmup
min:4940 max:8187 total:13127
min:4866 max:7876 total:12742
min:5815 max:5989 total:11804
min:5658 max:6697 total:12355
min:5861 max:5868 total:11729
min:5803 max:6031 total:11834
measurement
min:5386 max:6957 total:12343
average:12343
will-it-scale# ldd ./malloc1_threads
linux-vdso.so.1 (0x00007ffd97a8a000)
libhwloc.so.0 => /usr/lib/x86_64-linux-gnu/libhwloc.so.0 (0x00007fdf07c69000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fdf07c48000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdf07a87000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdf07904000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fdf078de000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdf07d01000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fdf078d4000)
BTW: make by gcc-9
The text was updated successfully, but these errors were encountered: