www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Need some help about error that I don't understand

reply Uranuz <neuranuz gmail.com> writes:
In my custom multithreaded web-server (non vibe-based) I got 
error that is strange for me. I've was looking for a reason 
running app under GDB, but I don't understand how to interpret 
what I've got.

It's interesting that it fails (without any error or segfault 
message) in the case when null reference to class object passed 
into static method of class. When it's not null all goes well. So 
there is backtrace:

//---------------
(gdb) thread apply all bt

Thread 4 (Thread 0x7ffff1cb1700 (LWP 30869)):
#0  sem_wait () at 
../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
#1  0x000000000084747f in core.thread.suspend() ()
#2  0x0000000000839467 in thread_suspendAll ()
#3  0x000000000082bd88 in gc.gc.Gcx.fullcollect() ()
#4  0x000000000082a43d in gc.gc.Gcx.bigAlloc() ()
#5  0x0000000000827ca5 in gc.gc.GC.malloc() ()
#6  0x00000000007f36cc in gc_malloc ()
#7  0x00000000007f09f0 in core.memory.GC.malloc() ()
#8  0x00000000008321cf in 
std.array.__T14arrayAllocImplVbi0TAhTmZ.arrayAllocImpl() ()
#9  0x00000000008321a1 in 
std.array.__T18uninitializedArrayTAhTymZ.uninitializedArray() ()
#10 0x0000000000806724 in std.file.readImpl() ()
#11 0x0000000000780b49 in std.file.__T4readTAyaZ.read() ()
#12 0x000000000073357c in mkk_site.utils.getPageTemplate() ()
#13 0x0000000000733243 in mkk_site.utils.getGeneralTemplate() ()
#14 0x000000000072ed8f in 
mkk_site.uri_page_router.MKK_Site_URIPageRouter.renderMessageBody() ()
#15 0x000000000072ecba in 
mkk_site.uri_page_router.MKK_Site_URIPageRouter.customProcessRequest() ()
#16 0x000000000079fa03 in 
webtank.net.http.handler.EventBasedHTTPHandler.processRequest() ()
#17 0x000000000079fc43 in 
webtank.net.http.handler.HTTPRouter.customProcessRequest() ()
#18 0x000000000079fa03 in 
webtank.net.http.handler.EventBasedHTTPHandler.processRequest() ()
#19 0x0000000000755692 in 
webtank.net.web_server.WorkingThread._work() ()
#20 0x00000000008257de in core.thread.Thread.run() ()
#21 0x0000000000825422 in thread_entryPoint ()
#22 0x00007ffff75ba182 in start_thread (arg=0x7ffff1cb1700) at 
pthread_create.c:312
#23 0x00007ffff70df47d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 3 (Thread 0x7ffff24b2700 (LWP 30860)):
#0  __lll_lock_wait () at 
../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007ffff75bc672 in _L_lock_953 () from 
/lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff75bc4da in __GI___pthread_mutex_lock 
(mutex=0xac58a0 <gc.gc.GC.mutexStorage()+16>)
     at ../nptl/pthread_mutex_lock.c:114
#3  0x00000000007f33b1 in core.sync.mutex.Mutex.lock_nothrow() ()
#4  0x0000000000827445 in gc.gc.GCMutex.lock() ()
#5  0x0000000000827c52 in gc.gc.GC.malloc() ()
#6  0x00000000007f36cc in gc_malloc ()
#7  0x00000000007f09f0 in core.memory.GC.malloc() ()
#8  0x000000000075985c in 
std.array.__T14arrayAllocImplVbi0TAaTmZ.arrayAllocImpl() ()
#9  0x0000000000759839 in 
std.array.__T18uninitializedArrayTAaTmZ.uninitializedArray() ()
#10 0x000000000075981d in 
std.array.__T5arrayTS3std4conv47__T7toCharsVii10TaVE3std5ascii10LetterCasei1TmZ7toCharsFNaNbNi
fmZ6ResultZ.array() ()
#11 0x000000000075978b in 
std.array.__T5arrayTS3std4conv47__T7toCharsVii10TaVE3std5ascii10LetterCasei1TmZ7toCharsFNaNbNi
fmZ6ResultZ.array() ()
#12 0x0000000000719122 in std.conv.__T6toImplTAyaTmZ.toImpl() ()
#13 0x00000000007190b3 in std.conv.__T6toImplTAyaTmZ.toImpl() ()
#14 0x0000000000719099 in std.conv.__T2toTAyaZ.__T2toTmZ.to() ()
#15 0x00000000007d1f04 in 
webtank.common.logger.FileLogger.writeEvent() ()
#16 0x00000000007d2183 in 
webtank.common.logger.ThreadedLogger._run() ()
#17 0x00000000007d4141 in 
std.concurrency.Message.__T3mapTDFS7webtank6common6logger8LogEventZvZ.map() ()
#18 0x00000000007d3a79 in 
std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
#19 0x00000000007d3e79 in 
std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
#20 0x00000000007d39a6 in 
std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
#21 0x00000000007d380b in 
std.concurrency.__T7receiveTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15OwnerTer
inatedZvZ.receive() ()
#22 0x00000000007d215b in 
webtank.common.logger.ThreadedLogger._run() ()
#23 0x00000000007d237d in 
std.concurrency.__T6_spawnTPFS3std11concurrency3TidOC7webtank6common6logger6LoggerZvTS3std11concurrency3TidTOC7webtank6common6log
er6LoggerZ._spawn() ()
---Type <return> to continue, or q <return> to quit---
#24 0x00000000008257de in core.thread.Thread.run() ()
#25 0x0000000000825422 in thread_entryPoint ()
#26 0x00007ffff75ba182 in start_thread (arg=0x7ffff24b2700) at 
pthread_create.c:312
#27 0x00007ffff70df47d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 2 (Thread 0x7ffff2cb3700 (LWP 30859)):
#0  pthread_cond_wait  GLIBC_2.3.2 () at 
../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x0000000000826f21 in core.sync.condition.Condition.wait() ()
#2  0x00000000007d3944 in 
std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
#3  0x00000000007d380b in 
std.concurrency.__T7receiveTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15OwnerTer
inatedZvZ.receive() ()
#4  0x00000000007d215b in 
webtank.common.logger.ThreadedLogger._run() ()
#5  0x00000000007d237d in 
std.concurrency.__T6_spawnTPFS3std11concurrency3TidOC7webtank6common6logger6LoggerZvTS3std11concurrency3TidTOC7webtank6common6log
er6LoggerZ._spawn() ()
#6  0x00000000008257de in core.thread.Thread.run() ()
#7  0x0000000000825422 in thread_entryPoint ()
#8  0x00007ffff75ba182 in start_thread (arg=0x7ffff2cb3700) at 
pthread_create.c:312
#9  0x00007ffff70df47d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7ffff7fbd980 (LWP 30855)):
#0  0x00007ffff75c16dd in accept () at 
../sysdeps/unix/syscall-template.S:81
#1  0x0000000000811db4 in std.socket.Socket.accept() ()
#2  0x00000000007551e7 in 
webtank.net.web_server.WebServer.start() ()
#3  0x0000000000718a45 in D main ()
#4  0x00000000007f569b in rt.dmain2._d_run_main() ()
#5  0x00000000007f55f1 in rt.dmain2._d_run_main() ()
#6  0x00000000007f5657 in rt.dmain2._d_run_main() ()
#7  0x00000000007f55f1 in rt.dmain2._d_run_main() ()
#8  0x00000000007f554e in _d_run_main ()
#9  0x0000000000725d1e in main ()
(gdb)

//---------------

In my app I have loger thread that receive messages through 
std.concurrency.receive and writes them into file. Could it be 
the source of problems?
Feb 05 2016
parent Uranuz <neuranuz gmail.com> writes:
On Friday, 5 February 2016 at 17:39:55 UTC, Uranuz wrote:
 In my custom multithreaded web-server (non vibe-based) I got 
 error that is strange for me. I've was looking for a reason 
 running app under GDB, but I don't understand how to interpret 
 what I've got.

 It's interesting that it fails (without any error or segfault 
 message) in the case when null reference to class object passed 
 into static method of class. When it's not null all goes well. 
 So there is backtrace:

 //---------------
 (gdb) thread apply all bt

 Thread 4 (Thread 0x7ffff1cb1700 (LWP 30869)):
 #0  sem_wait () at 
 ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
 #1  0x000000000084747f in core.thread.suspend() ()
 #2  0x0000000000839467 in thread_suspendAll ()
 #3  0x000000000082bd88 in gc.gc.Gcx.fullcollect() ()
 #4  0x000000000082a43d in gc.gc.Gcx.bigAlloc() ()
 #5  0x0000000000827ca5 in gc.gc.GC.malloc() ()
 #6  0x00000000007f36cc in gc_malloc ()
 #7  0x00000000007f09f0 in core.memory.GC.malloc() ()
 #8  0x00000000008321cf in 
 std.array.__T14arrayAllocImplVbi0TAhTmZ.arrayAllocImpl() ()
 #9  0x00000000008321a1 in 
 std.array.__T18uninitializedArrayTAhTymZ.uninitializedArray() ()
 #10 0x0000000000806724 in std.file.readImpl() ()
 #11 0x0000000000780b49 in std.file.__T4readTAyaZ.read() ()
 #12 0x000000000073357c in mkk_site.utils.getPageTemplate() ()
 #13 0x0000000000733243 in mkk_site.utils.getGeneralTemplate() ()
 #14 0x000000000072ed8f in 
 mkk_site.uri_page_router.MKK_Site_URIPageRouter.renderMessageBody() ()
 #15 0x000000000072ecba in 
 mkk_site.uri_page_router.MKK_Site_URIPageRouter.customProcessRequest() ()
 #16 0x000000000079fa03 in 
 webtank.net.http.handler.EventBasedHTTPHandler.processRequest() 
 ()
 #17 0x000000000079fc43 in 
 webtank.net.http.handler.HTTPRouter.customProcessRequest() ()
 #18 0x000000000079fa03 in 
 webtank.net.http.handler.EventBasedHTTPHandler.processRequest() 
 ()
 #19 0x0000000000755692 in 
 webtank.net.web_server.WorkingThread._work() ()
 #20 0x00000000008257de in core.thread.Thread.run() ()
 #21 0x0000000000825422 in thread_entryPoint ()
 #22 0x00007ffff75ba182 in start_thread (arg=0x7ffff1cb1700) at 
 pthread_create.c:312
 #23 0x00007ffff70df47d in clone () at 
 ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

 Thread 3 (Thread 0x7ffff24b2700 (LWP 30860)):
 #0  __lll_lock_wait () at 
 ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
 #1  0x00007ffff75bc672 in _L_lock_953 () from 
 /lib/x86_64-linux-gnu/libpthread.so.0
 #2  0x00007ffff75bc4da in __GI___pthread_mutex_lock 
 (mutex=0xac58a0 <gc.gc.GC.mutexStorage()+16>)
     at ../nptl/pthread_mutex_lock.c:114
 #3  0x00000000007f33b1 in core.sync.mutex.Mutex.lock_nothrow() 
 ()
 #4  0x0000000000827445 in gc.gc.GCMutex.lock() ()
 #5  0x0000000000827c52 in gc.gc.GC.malloc() ()
 #6  0x00000000007f36cc in gc_malloc ()
 #7  0x00000000007f09f0 in core.memory.GC.malloc() ()
 #8  0x000000000075985c in 
 std.array.__T14arrayAllocImplVbi0TAaTmZ.arrayAllocImpl() ()
 #9  0x0000000000759839 in 
 std.array.__T18uninitializedArrayTAaTmZ.uninitializedArray() ()
 #10 0x000000000075981d in 
 std.array.__T5arrayTS3std4conv47__T7toCharsVii10TaVE3std5ascii10LetterCasei1TmZ7toCharsFNaNbNi
fmZ6ResultZ.array() ()
 #11 0x000000000075978b in 
 std.array.__T5arrayTS3std4conv47__T7toCharsVii10TaVE3std5ascii10LetterCasei1TmZ7toCharsFNaNbNi
fmZ6ResultZ.array() ()
 #12 0x0000000000719122 in std.conv.__T6toImplTAyaTmZ.toImpl() ()
 #13 0x00000000007190b3 in std.conv.__T6toImplTAyaTmZ.toImpl() ()
 #14 0x0000000000719099 in std.conv.__T2toTAyaZ.__T2toTmZ.to() ()
 #15 0x00000000007d1f04 in 
 webtank.common.logger.FileLogger.writeEvent() ()
 #16 0x00000000007d2183 in 
 webtank.common.logger.ThreadedLogger._run() ()
 #17 0x00000000007d4141 in 
 std.concurrency.Message.__T3mapTDFS7webtank6common6logger8LogEventZvZ.map() ()
 #18 0x00000000007d3a79 in 
 std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
 #19 0x00000000007d3e79 in 
 std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
 #20 0x00000000007d39a6 in 
 std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
 #21 0x00000000007d380b in 
 std.concurrency.__T7receiveTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15OwnerTer
inatedZvZ.receive() ()
 #22 0x00000000007d215b in 
 webtank.common.logger.ThreadedLogger._run() ()
 #23 0x00000000007d237d in 
 std.concurrency.__T6_spawnTPFS3std11concurrency3TidOC7webtank6common6logger6LoggerZvTS3std11concurrency3TidTOC7webtank6common6log
er6LoggerZ._spawn() ()
 ---Type <return> to continue, or q <return> to quit---
 #24 0x00000000008257de in core.thread.Thread.run() ()
 #25 0x0000000000825422 in thread_entryPoint ()
 #26 0x00007ffff75ba182 in start_thread (arg=0x7ffff24b2700) at 
 pthread_create.c:312
 #27 0x00007ffff70df47d in clone () at 
 ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

 Thread 2 (Thread 0x7ffff2cb3700 (LWP 30859)):
 #0  pthread_cond_wait  GLIBC_2.3.2 () at 
 ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
 #1  0x0000000000826f21 in core.sync.condition.Condition.wait() 
 ()
 #2  0x00000000007d3944 in 
 std.concurrency.MessageBox.__T3getTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15Owne
TerminatedZvZ.get() ()
 #3  0x00000000007d380b in 
 std.concurrency.__T7receiveTDFS7webtank6common6logger8LogEventZvTDFNaNbNiNfS7webtank6common6logger14ThreadedLogger10LogStopMsgZvTDFC3std11concurrency15OwnerTer
inatedZvZ.receive() ()
 #4  0x00000000007d215b in 
 webtank.common.logger.ThreadedLogger._run() ()
 #5  0x00000000007d237d in 
 std.concurrency.__T6_spawnTPFS3std11concurrency3TidOC7webtank6common6logger6LoggerZvTS3std11concurrency3TidTOC7webtank6common6log
er6LoggerZ._spawn() ()
 #6  0x00000000008257de in core.thread.Thread.run() ()
 #7  0x0000000000825422 in thread_entryPoint ()
 #8  0x00007ffff75ba182 in start_thread (arg=0x7ffff2cb3700) at 
 pthread_create.c:312
 #9  0x00007ffff70df47d in clone () at 
 ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

 Thread 1 (Thread 0x7ffff7fbd980 (LWP 30855)):
 #0  0x00007ffff75c16dd in accept () at 
 ../sysdeps/unix/syscall-template.S:81
 #1  0x0000000000811db4 in std.socket.Socket.accept() ()
 #2  0x00000000007551e7 in 
 webtank.net.web_server.WebServer.start() ()
 #3  0x0000000000718a45 in D main ()
 #4  0x00000000007f569b in rt.dmain2._d_run_main() ()
 #5  0x00000000007f55f1 in rt.dmain2._d_run_main() ()
 #6  0x00000000007f5657 in rt.dmain2._d_run_main() ()
 #7  0x00000000007f55f1 in rt.dmain2._d_run_main() ()
 #8  0x00000000007f554e in _d_run_main ()
 #9  0x0000000000725d1e in main ()
 (gdb)

 //---------------

 In my app I have loger thread that receive messages through 
 std.concurrency.receive and writes them into file. Could it be 
 the source of problems?
I entirely removed loging functionality but still have another error: (gdb) thread apply all bt Thread 2 (Thread 0x7ffff2cb3700 (LWP 31995)): #0 sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85 #1 0x0000000000846aaf in core.thread.suspend() () #2 0x0000000000838a97 in thread_suspendAll () #3 0x000000000082b3b8 in gc.gc.Gcx.fullcollect() () #4 0x0000000000829a6d in gc.gc.Gcx.bigAlloc() () #5 0x00000000008272d5 in gc.gc.GC.malloc() () #6 0x00000000007f2cfc in gc_malloc () #7 0x00000000007f0020 in core.memory.GC.malloc() () #8 0x00000000008317ff in std.array.__T14arrayAllocImplVbi0TAhTmZ.arrayAllocImpl() () #9 0x00000000008317d1 in std.array.__T18uninitializedArrayTAhTymZ.uninitializedArray() () #10 0x0000000000805d54 in std.file.readImpl() () #11 0x0000000000780179 in std.file.__T4readTAyaZ.read() () #12 0x0000000000732c6c in mkk_site.utils.getPageTemplate() () #13 0x0000000000732933 in mkk_site.utils.getGeneralTemplate() () #14 0x000000000072e47f in mkk_site.uri_page_router.MKK_Site_URIPageRouter.renderMessageBody() () #15 0x000000000072e3aa in mkk_site.uri_page_router.MKK_Site_URIPageRouter.customProcessRequest() () #16 0x000000000079f033 in webtank.net.http.handler.EventBasedHTTPHandler.processRequest() () #17 0x000000000079f273 in webtank.net.http.handler.HTTPRouter.customProcessRequest() () #18 0x000000000079f033 in webtank.net.http.handler.EventBasedHTTPHandler.processRequest() () #19 0x0000000000754d82 in webtank.net.web_server.WorkingThread._work() () #20 0x0000000000824e0e in core.thread.Thread.run() () #21 0x0000000000824a52 in thread_entryPoint () #22 0x00007ffff75ba182 in start_thread (arg=0x7ffff2cb3700) at pthread_create.c:312 #23 0x00007ffff70df47d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 Thread 1 (Thread 0x7ffff7fbd980 (LWP 31988)): #0 0x00007ffff75c16dd in accept () at ../sysdeps/unix/syscall-template.S:81 #1 0x00000000008113e4 in std.socket.Socket.accept() () #2 0x00000000007548d7 in webtank.net.web_server.WebServer.start() () #3 0x000000000071819d in D main () #4 0x00000000007f4ccb in rt.dmain2._d_run_main() () #5 0x00000000007f4c21 in rt.dmain2._d_run_main() () #6 0x00000000007f4c87 in rt.dmain2._d_run_main() () #7 0x00000000007f4c21 in rt.dmain2._d_run_main() () #8 0x00000000007f4b7e in _d_run_main () #9 0x000000000072540e in main () (gdb) Notice that there is only 2 threads. I was having two loging threads each loging to it's individual file.
Feb 05 2016