Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #90715

Re: [C/POSIX] pthread_exit()

From Johann Klammer <klammerj@NOSPAM.a1.net>
Newsgroups comp.lang.c
Subject Re: [C/POSIX] pthread_exit()
Date 2016-07-21 11:54 +0200
Organization Aioe.org NNTP Server
Message-ID <nmq64c$1sjs$1@gioia.aioe.org> (permalink)
References <slrnnovao6.boo.jkb@rayleigh.systella.fr>

Show all headers | View raw


On 07/20/2016 06:47 PM, JKB wrote:
> 	Hello,
> 
> 	I'm debugging a huge program that can enter in deadlock on a
> 	pthread_exit() syscall. I use gcc compiler on Linux or NetBSD.
> 
> 	Before writing here, I have tried to debug this program with
> 	valgrind and helgrind without any success. I have tried Purify also.
> 
> 	Original program is available at :
> 	http://www.rpl2.net/telechargements.php -> snapshot
> 
> 	With following test program :
> 
> #!/usr/local/bin/rpl -spd
> TEST
> <<
> 	0 -> I
> 	<< do 'TEST2' detach wfproc 'I' incr I disp until false end >>
>>>
> 
> TEST2
> <<
>>>
> 
> 	rpl enters in deadlock after a random number of cycles in do/until
> 	loop. I have checked all memory access and I haven't found any memory
> 	corruption. For example, last time I have launched my test program,
> 	execution stops with :
> 
> ...
> 1090390
> 1090391
> 1090392
> 1090393
> 1090394
> 1090395
> 1090396
> 1090397
> 
> 	With gdb, I can obtain a backtrace of faulty thread :
> 
> (gdb) bt
> #0  __lll_lock_wait () at
> ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
> #1  0x00007f9ebbb0bb92 in __GI___pthread_mutex_lock (
>     mutex=0x7f9ebc674970 <_rtld_global+2352>)
>     at ../nptl/pthread_mutex_lock.c:116
> #2  0x00007f9ebb1fdbaf in __GI___dl_iterate_phdr
> 	(callback=0x7f9ebaedae40, 
>     data=0x7f9eb9c878b0) at dl-iteratephdr.c:41
> #3  0x00007f9ebaedc1be in _Unwind_Find_FDE ()
>     from /lib/x86_64-linux-gnu/libgcc_s.so.1
> #4  0x00007f9ebaed8bb3 in ?? () from
>     /lib/x86_64-linux-gnu/libgcc_s.so.1
> #5  0x00007f9ebaed9dd0 in ?? () from
>     /lib/x86_64-linux-gnu/libgcc_s.so.1
> #6  0x00007f9ebaeda3d6 in _Unwind_ForcedUnwind ()
>     from /lib/x86_64-linux-gnu/libgcc_s.so.1
> #7  0x00007f9ebbb11ae0 in __GI___pthread_unwind
>     (buf=<optimized out>) at unwind.c:126
> #8  0x00007f9ebbb0a5a5 in __do_cancel () at pthreadP.h:283
> #9  __pthread_exit (value=value@entry=0x0) at pthread_exit.c:28
> ...
> 
> 	Each time, one of the pthread_exit() syscall in src/interruptions.c
> 	enter in deadlock. I have tried to relink my program with -Wl,-z,now
> 	as I have seen some very similar issue on internet, but it doesn't
> 	fix my trouble.
> 	
> 	How can I debug this mistake ?
> 
> 	Regards,
> 
> 	JB
> 

It waits for an internal mutex. 
You'll have to check the other threads for locks..
I think the gdb commands were:

`info threads'
and
`thread <n>'
to switch betw them.

use backtrace as before and perhaps you'll find it.
Also check that the thread structure has not been destroyed early, 
if the pthread_t itself sits in a malloced block.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-20 16:47 +0000
  Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-20 13:42 -0400
    Re: [C/POSIX] pthread_exit() Keith Thompson <kst-u@mib.org> - 2016-07-20 11:33 -0700
    Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-21 10:10 +0000
    Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-22 08:10 -0500
      Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 13:42 +0000
        Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-22 09:44 -0500
          Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 14:48 +0000
      Re: [C/POSIX] pthread_exit() Richard Heathfield <rjh@cpax.org.uk> - 2016-07-22 14:52 +0100
      Re: [C/POSIX] pthread_exit() supercat@casperkitty.com - 2016-07-22 08:51 -0700
      Re: [C/POSIX] pthread_exit() James Kuyper <jameskuyper@verizon.net> - 2016-07-22 13:26 -0400
      Re: [C/POSIX] pthread_exit() Keith Thompson <kst-u@mib.org> - 2016-07-22 10:28 -0700
        Re: [C/POSIX] pthread_exit() Ian Collins <ian-news@hotmail.com> - 2016-07-23 16:12 +1200
        Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-23 16:43 -0500
          Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-23 18:17 -0400
            Re: [C/POSIX] pthread_exit() Keith Thompson <kst-u@mib.org> - 2016-07-23 20:45 -0700
            Re: [C/POSIX] pthread_exit() James Kuyper <jameskuyper@verizon.net> - 2016-07-24 07:27 -0400
              Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-25 15:22 -0500
                Re: [C/POSIX] pthread_exit() Ian Collins <ian-news@hotmail.com> - 2016-07-26 08:26 +1200
                Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-25 16:32 -0400
                Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-25 15:52 -0500
                Re: [C/POSIX] pthread_exit() "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-25 16:59 -0400
                Re: [C/POSIX] pthread_exit() Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-25 16:36 -0500
  Re: [C/POSIX] pthread_exit() Johann Klammer <klammerj@NOSPAM.a1.net> - 2016-07-21 11:54 +0200
    Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 08:17 +0000
      Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-22 08:47 +0000
  Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-23 00:52 +0200
    Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 11:43 +0000
      Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 13:47 +0200
        Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 11:58 +0000
          Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 14:00 +0200
            Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 12:18 +0000
              Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 14:20 +0200
                Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 12:26 +0000
                Re: [C/POSIX] pthread_exit() Melzzzzz <mel@zzzzz.com> - 2016-07-25 14:28 +0200
                Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 12:35 +0000
                Re: [C/POSIX] pthread_exit() JKB <jkb@koenigsberg.invalid> - 2016-07-25 13:44 +0000

csiph-web