www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20578] New: Parallel GC causes segfault in dl

https://issues.dlang.org/show_bug.cgi?id=20578

          Issue ID: 20578
           Summary: Parallel GC causes segfault in dl
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net
                CC: r.sagitario gmx.de

I'm seeing the following problem on an Ubuntu 16.04 server:

===============================================================================
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /tmp/gc-test/test_program...done.
Starting program: /tmp/gc-test/test_program --help
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7ff7700 (LWP 16618)]
[New Thread 0x7ffff7ff3700 (LWP 16619)]
[New Thread 0x7ffff7fef700 (LWP 16620)]
[New Thread 0x7ffff7feb700 (LWP 16621)]
[New Thread 0x7ffff7fe7700 (LWP 16622)]
[New Thread 0x7ffff7fe3700 (LWP 16623)]
[New Thread 0x7ffff7fd8700 (LWP 16624)]

Thread 2 "test_program" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7ff7700 (LWP 16618)]
0x00007ffff7de8981 in _dl_name_match_p (name=0x51b9b2 "libc.so.6",
map=map entry=0x7ffff7ffe168) at dl-misc.c:288
288     dl-misc.c: No such file or directory.
(gdb) where

map=map entry=0x7ffff7ffe168) at dl-misc.c:288

"sched_yield", new_hash=new_hash entry=3838766306, 
    old_hash=old_hash entry=0x7ffff7ff5160, ref=0x44bcf8,
result=result entry=0x7ffff7ff5170, scope=<optimised out>, i=<optimised out>, 
    version=0x7ffff7fdd700, flags=5, skip=0x0, type_class=1,
undef_map=0x7ffff7ffe168) at dl-lookup.c:554

"sched_yield", undef_map=0x7ffff7ffe168, ref=ref entry=0x7ffff7ff5228, 
    symbol_scope=0x7ffff7ffe4c0, version=0x7ffff7fdd700,
type_class=type_class entry=1, flags=5, skip_map=0x0) at dl-lookup.c:829

out>) at ../elf/dl-runtime.c:111

../sysdeps/x86_64/dl-trampoline.h:112



../sysdeps/x86_64/dl-trampoline.h:112
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(failed reverse-i-search)`thread': Quit
(gdb) thread apply all backtrace

Thread 8 (Thread 0x7ffff7fd8700 (LWP 16624)):

../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

_D4core4sync5event5Event4waitMFNbNiSQBi4time8DurationZb ()

_D2gc4impl12conservativeQw3Gcx__T21pullFromScanStackImplVbi0ZQBcMFNbZv ()

()

_D4core6thread8osthread20createLowLevelThreadFNbNiDFNbZvkDFNbZvZ20thread_lowlevelEntryUNbPvZQd
()

pthread_create.c:333

../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 7 (Thread 0x7ffff7fe3700 (LWP 16623)):

../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

_D4core4sync5event5Event4waitMFNbNiSQBi4time8DurationZb ()

_D2gc4impl12conservativeQw3Gcx__T21pullFromScanStackImplVbi0ZQBcMFNbZv ()

()

_D4core6thread8osthread20createLowLevelThreadFNbNiDFNbZvkDFNbZvZ20thread_lowlevelEntryUNbPvZQd
()

pthread_create.c:333

../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 6 (Thread 0x7ffff7fe7700 (LWP 16622)):

../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

_D4core4sync5event5Event4waitMFNbNiSQBi4time8DurationZb ()

_D2gc4impl12conservativeQw3Gcx__T21pullFromScanStackImplVbi0ZQBcMFNbZv ()

()

_D4core6thread8osthread20createLowLevelThreadFNbNiDFNbZvkDFNbZvZ20thread_lowlevelEntryUNbPvZQd
()

pthread_create.c:333

../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 5 (Thread 0x7ffff7feb700 (LWP 16621)):

../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

_D4core4sync5event5Event4waitMFNbNiSQBi4time8DurationZb ()

_D2gc4impl12conservativeQw3Gcx__T21pullFromScanStackImplVbi0ZQBcMFNbZv ()

()

_D4core6thread8osthread20createLowLevelThreadFNbNiDFNbZvkDFNbZvZ20thread_lowlevelEntryUNbPvZQd
()

pthread_create.c:333

../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 4 (Thread 0x7ffff7fef700 (LWP 16620)):

../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

_D4core4sync5event5Event4waitMFNbNiSQBi4time8DurationZb ()

_D2gc4impl12conservativeQw3Gcx__T21pullFromScanStackImplVbi0ZQBcMFNbZv ()

()

_D4core6thread8osthread20createLowLevelThreadFNbNiDFNbZvkDFNbZvZ20thread_lowlevelEntryUNbPvZQd
()

pthread_create.c:333

../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7ffff7ff3700 (LWP 16619)):

../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

_D4core4sync5event5Event4waitMFNbNiSQBi4time8DurationZb ()

_D2gc4impl12conservativeQw3Gcx__T21pullFromScanStackImplVbi0ZQBcMFNbZv ()

()

_D4core6thread8osthread20createLowLevelThreadFNbNiDFNbZvkDFNbZvZ20thread_lowlevelEntryUNbPvZQd
()

pthread_create.c:333

../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7ffff7ff7700 (LWP 16618)):

map=map entry=0x7ffff7ffe168) at dl-misc.c:288

"sched_yield", new_hash=new_hash entry=3838766306,
old_hash=old_hash entry=0x7ffff7ff5160, ref=0x44bcf8,
result=result entry=0x7ffff7ff5170, scope=<optimised out>, i=<optimised out>, 
    version=0x7ffff7fdd700, flags=5, skip=0x0, type_class=1,
undef_map=0x7ffff7ffe168) at dl-lookup.c:554

"sched_yield", undef_map=0x7ffff7ffe168, ref=ref entry=0x7ffff7ff5228,
symbol_scope=0x7ffff7ffe4c0, version=0x7ffff7fdd700,
type_class=type_class entry=1, flags=5, skip_map=0x0) at dl-lookup.c:829

out>) at ../elf/dl-runtime.c:111

../sysdeps/x86_64/dl-trampoline.h:112



../sysdeps/x86_64/dl-trampoline.h:112
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Thread 1 (Thread 0x7ffff7fdae80 (LWP 16614)):

../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

_D4core4sync5event5Event4waitMFNbNiSQBi4time8DurationZb ()

_D2gc4impl12conservativeQw3Gcx__T21pullFromScanStackImplVbi0ZQBcMFNbZv ()

()


_D2gc4impl12conservativeQw3Gcx10smallAllocMFNbmKmkxC8TypeInfoZPv ()

_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS_DQEgQEgQEeQEp10mallocTimelS_DQFiQFiQFgQFr10numMallocslTmTkTmTxQCzZQFcMFNbKmKkKmKxQDsZQDl
()

_D2gc4impl12conservativeQw14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv ()


_D2rt3aaA11fakeEntryTIFKSQxQw4ImplxC8TypeInfoxQlZC15TypeInfo_Struct ()

_D2rt3aaA4Impl6__ctorMFNcMxC25TypeInfo_AssociativeArraymZSQCeQCeQCd ()



_D3std6getopt__T10getoptImplTAyaTPbZQuFNfKAQoKSQBtQBs13configurationKSQCqQCp12GetoptResultKCQDmQDl15GetOptExceptionHQDjAvQgQDqQDpZv
(_param_7=0x7fffffffd9d0, _param_6=..., visitedShortOpts=...,
visitedLongOpts=..., excep= 0x7fffffffd908: 0x0, 
    rslt=..., cfg=..., args=...) at
/home/vladimir/dlang/dmd-2.090.0/linux/bin64/../../src/phobos/std/getopt.d:727

_D3std6getopt__T10getoptImplTAyaTPbTQhTQgZQBaFNfKAQvKSQCaQBz13configurationKSQCxQCw12GetoptResultKCQDtQDs15GetOptExceptionHQDqAvQgQDxQDwQEdQEcZv
(_param_9=0x7fffffffd9d0, _param_8=..., _param_7=0x7fffffffd990, _param_6=..., 
    visitedShortOpts=..., visitedLongOpts=..., excep= 0x7fffffffd908: 0x0,
rslt=..., cfg=..., args=...) at
/home/vladimir/dlang/dmd-2.090.0/linux/bin64/../../src/phobos/std/getopt.d:762

_D3std6getopt__T10getoptImplTEQBcQBb6configTAyaTPbTQhTQgZQBpFNfKAQvKSQCpQCo13configurationKSQDmQDl12GetoptResultKCQEiQEh15GetOptExceptionHQDqAvQgQEmQEaQDzQEgQEfZv
(_param_10=0x7fffffffd9d0, _param_9=..., _param_8=0x7fffffffd990, _param_7=..., 
    _param_6=<incomplete type>, visitedShortOpts=..., visitedLongOpts=...,
excep= 0x7fffffffd908: 0x0, rslt=..., cfg=..., args=...) at
/home/vladimir/dlang/dmd-2.090.0/linux/bin64/../../src/phobos/std/getopt.d:699

_D3std6getopt__TQkTEQsQq6configTAyaTPbTQhTQgZQBnFNfKAQvQBkQBaQzQBfQBeZSQCrQCq12GetoptResult
(rslt=0x7fffffffd9e0, _param_5=0x7fffffffd9d0, _param_4=...,
_param_3=0x7fffffffd990, _param_2=..., _param_1=<incomplete type>, args=...)
    at
/home/vladimir/dlang/dmd-2.090.0/linux/bin64/../../src/phobos/std/getopt.d:435

_D2ae5utils6funopt__TQkS_DQyQxQt18__unittest_L636_C1FZ7Actions2f1FbZvVSQCrQCrQCo12FunOptConfigS1nS_DQDuQDuQDr__T14funoptDispatchTSQEyQEyQEvQEdFZQDmVQDaS1nS_DQFzQFzQFwQFeFZ8usageFunFNbNiNfAyaZvZQDdFAQlZ3funMFQuQmZ__T12descUsageFunVQBra17_506572666f726d20616374696f6e206631ZQCfFNbNfQDpZvZQKpFQDpZv
(args=...) at lib/ae/utils/funopt.d:245

_D2ae5utils6funopt__T14funoptDispatchTSQBlQBlQBi18__unittest_L636_C1FZ7ActionsVSQDaQDaQCx12FunOptConfigS1nS_DQEdQEdQEaQCsFZ8usageFunFNbNiNfAyaZvZQEuFAQlZ3funMFQuQmZv
(__capture=0x7ffff7fd2660, actionArguments=..., action=...)
    at lib/ae/utils/funopt.d:594

_D2ae5utils6funopt__TQkS_DQyQxQt__T14funoptDispatchTSQBzQBzQBw18__unittest_L636_C1FZ7ActionsVSQDoQDoQDl12FunOptConfigS1nS_DQErQErQEoQCsFZ8usageFunFNbNiNfAyaZvZQEuFAQlZ3funMFQuQmZvVQDjS1A1i6S_DQHiQHiQHf__TQGnTQGaVQEpS1nS_DQIlQIlQIiQGmFZQDuQDoZQHzFQDfZ10myUsageFunFQEgZvZQJyMFQEhZv
(__capture=0x7ffff7fd2660, args=...) at lib/ae/utils/funopt.d:302

_D2ae5utils6funopt__T14funoptDispatchTSQBlQBlQBi18__unittest_L636_C1FZ7ActionsVSQDaQDaQCx12FunOptConfigS1nS_DQEdQEdQEaQCsFZ8usageFunFNbNiNfAyaZvZQEuFAQlZv
(args=...) at lib/ae/utils/funopt.d:608

lib/ae/utils/funopt.d:668


core.runtime.runModuleUnitTests().__foreachbody2(object.ModuleInfo*) ()

_D6object10ModuleInfo7opApplyFMDFPSQBhQBdZiZ9__lambda2MFyPSQCfQCbZi ()

_D2rt5minfo17moduleinfos_applyFMDFyPS6object10ModuleInfoZiZ14__foreachbody2MFKSQCz19sections_elf_shared3DSOZi
()

_D2rt19sections_elf_shared3DSO7opApplyFMDFKSQBqQBqQyZiZi ()

int(immutable(object.ModuleInfo*)) delegate) ()




_D2rt6dmain212_d_run_main2UAAamPUQgZiZ7tryExecMFMDFZvZv ()



/home/vladimir/dlang/dmd-2.090.0/linux/bin64/../../src/druntime/import/core/internal/entrypoint.d:34

argv=0x7fffffffe4b8, init=<optimised out>, fini=<optimised out>,
rtld_fini=<optimised out>, stack_end=0x7fffffffe4a8) at ../csu/libc-start.c:291

===============================================================================

The program crashes in this manner about 50% of the time on start-up.

The program was compiled with DMD 2.090.0, with -g -debug -cov.

The problem does not occur if parallel GC is switched off using
--DRT-gcopt=parallel:0.

I'm not sure why dl and the GC are running at the same time. It looks like it
is trying to link sched_yield lazily? Perhaps there is a thread safety bug in
(this version of) dl?

--
Feb 12 2020