Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#11816 closed bug (duplicate)

pthread pthread_attr_setdetachstate crash

Reported by: kallisti5 Owned by: axeld
Priority: normal Milestone: R1
Component: System/libroot.so Version: R1/Development
Keywords: pthread_attr_setdetachstate Cc:
Blocked By: Blocking: #11815
Platform: All

Description

http://sourceforge.net/projects/posixtest/files/posixtest/posixtestsuite-1.5.2/

  • gcc -I./include ./conformance/interfaces/pthread_attr_setdetachstate/2-1.c -g
  • LD_PRELOAD=libroot_debug.so ./a.out
KERN: 30030: DEBUGGER: _numBlocks > 0
KERN: debug_server: Thread 30030 entered the debugger: Debugger call: `_numBlocks > 0'
KERN: stack trace, current PC 0x1d3a70d4fc9  _kern_debugger + 0x9:
KERN:   (0x7f1f9b181360)  0x1d3a7178f5e  _ZN8BPrivate11processHeap4freeEPv + 0x18e
KERN:   (0x7f1f9b1813a0)  0x1d3a7179aa0  free + 0x40
KERN:   (0x7f1f9b1813c0)  0x1d3a70e2598  pthread_join + 0x88
KERN:   (0x7f1f9b181400)  0x13d1368dc42  main + 0x9d
KERN:   (0x7f1f9b181430)  0x13d1368dac1  _start + 0x51
KERN:   (0x7f1f9b181460)  0x7977d707e3  runtime_loader + 0xf3
KERN: debug_server: Killing team 30030 (./a.out)
KERN: debug_server: TeamDebugHandler::Init(): Failed to get info for team 30030: Operation on invalid team
KERN: debug_server: KillTeam(): Error getting info for team 30030: Operation on invalid team
KERN: debug_server: Killing team 30030 ()
KERN: 30049: DEBUGGER: _numBlocks > 0

Change History (7)

comment:1 by kallisti5, 9 years ago

libroot/posix/malloc/superblock.h:  superblock::isValid(void)
libroot/posix/malloc/superblock.h:      assert(_numBlocks > 0);

comment:2 by kallisti5, 9 years ago

libroot/posix/pthread/pthread.cpp:189:pthread_join(pthread_t thread, void** _value)
.
.
    if ((atomic_or(&thread->flags, THREAD_DETACHED) & THREAD_DEAD) != 0)
        free(thread);
.

comment:3 by anevilyak, 9 years ago

This looks like the same exact crash as #8836. In the latter case, it's entirely expected due to the pthread spec indicating that performing a join on a detached thread is undefined behavior.

comment:4 by kallisti5, 9 years ago

Per Pulkomandy, I tested with this version instead: https://github.com/haiku/open_posix_testsuite

Same crash.

comment:6 by kallisti5, 9 years ago

@anevilyak,

ah, you're right.. this is a dup of #8863.

However, if using a thread in this way is common... won't this effect the stability of ports?

Version 0, edited 9 years ago by kallisti5 (next)

comment:7 by kallisti5, 9 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.