Issue 12 in thread-sanitizer: SEGV in pthread_create with TSan

166 views
Skip to first unread message

thread-s...@googlecode.com

unread,
Feb 13, 2013, 4:06:15 AM2/13/13
to thread-s...@googlegroups.com
Status: Accepted
Owner: dvyu...@google.com
Labels: Type-Defect Priority-Medium

New issue 12 by euge...@google.com: SEGV in pthread_create with TSan
http://code.google.com/p/thread-sanitizer/issues/detail?id=12

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

void *threadfn(void*) {
return NULL;
}
void *allocate_stack(pthread_attr_t &a, size_t n = 655360) {
void *stack = malloc(n);
pthread_attr_init(&a);
pthread_attr_setstack(&a, stack, n);
return stack;
}

int main(void) {
pthread_attr_t a;
allocate_stack(a);
pthread_t t;
pthread_create(&t, &a, threadfn, NULL);
}

# clang++ 1.cc -o 1 -lpthread -fPIE -pie -fsanitize=thread -O0 -g
# ./1
Segmentation fault (core dumped)

Debugging is diffucult:
# gdb ./1
(gdb) set disable-randomization off
(gdb) run

[...]

Program received signal SIGSEGV, Segmentation fault.
memset () at ../sysdeps/x86_64/multiarch/../memset.S:1285
1285 ../sysdeps/x86_64/multiarch/../memset.S: No such file or directory.
(gdb) bt
#0 memset () at ../sysdeps/x86_64/multiarch/../memset.S:1285
#1 0x00007f4e2f1e5ef7 in __GI__dl_allocate_tls_init
(result=0x7f4e2e1e1700) at dl-tls.c:437
#2 0x00007f4e2efbf6f3 in allocate_stack (
../../gdb-7.5.x/gdb/dwarf2read.c:10202: internal-error:
dwarf2_record_block_ranges: Assertion `dwarf2_per_objfile->ranges.readin'
failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)


Note that allocate_stack in the stack trace above refers to a function in
glibc (called from pthread_create).

Increasing allocated stack size even further "fixes" the problem.

thread-s...@googlecode.com

unread,
Apr 2, 2013, 4:07:36 PM4/2/13
to thread-s...@googlegroups.com

Comment #1 on issue 12 by fakju66...@o2.pl: SEGV in pthread_create with TSan
http://code.google.com/p/thread-sanitizer/issues/detail?id=12

Is this still an issue? I can't reproduce in trunk.

I'm particularly after the GDB assertion, I constantly hit it and am
looking for a minimized testcase to report to GDB devs.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

thread-s...@googlecode.com

unread,
Apr 2, 2013, 8:32:16 PM4/2/13
to thread-s...@googlegroups.com

Comment #2 on issue 12 by fakju66...@o2.pl: SEGV in pthread_create with TSan
http://code.google.com/p/thread-sanitizer/issues/detail?id=12

In fact, I can't reproduce even with clang from Feb 14th:

llvm: git rev 382a5530ec0682d8dd17f7d9212f52ace38460ed
clang: git rev 8c42a67645145a7673d0313da7dcbab2b66f5611
compiler-rt: git rev 8da17ea3bc3ba0a28844642921247a3b9a1a3bcd

$ /home/name/src/llvm-feb14/obj/Release+Asserts/bin/clang++ 1.cc -o 1
-lpthread -fPIE -pie -fsanitize=thread -O0 -g
$ ./1
==================
WARNING: ThreadSanitizer: thread leak (pid=2416)
Thread T1 (tid=2417, finished) created by main thread at:
#0 pthread_create ??:0 (exe+0x00000001884a)
#1 main /home/name/src/gdbcrash/1.cc:20 (exe+0x000000013955)

SUMMARY: ThreadSanitizer: thread leak ??:0 pthread_create
==================
ThreadSanitizer: reported 1 warnings

OS: Ubuntu 12.04.2 64bit

Maybe it's arch specific?

thread-s...@googlecode.com

unread,
Apr 3, 2013, 4:11:06 AM4/3/13
to thread-s...@googlegroups.com

Comment #3 on issue 12 by euge...@google.com: SEGV in pthread_create with
TSan
http://code.google.com/p/thread-sanitizer/issues/detail?id=12

I can't reproduce the TSan segmentation fault, but GDB assertion is still
here.

(gdb) set disable-randomization off
(gdb) run
...
[Inferior 1 (process 11240) exited with code 0102]
(gdb) br __GI__dl_allocate_tls_init
Breakpoint 1 at 0x7ffad35dfe10: file dl-tls.c, line 377.
(gdb) run
Starting program: /code/llvm/1

Breakpoint 1, __GI__dl_allocate_tls_init (result=0x7f3631e18fc0) at
dl-tls.c:377
377 dl-tls.c: No such file or directory.
(gdb) br memset
../../gdb-7.5.x/gdb/dwarf2read.c:10202: internal-error:
dwarf2_record_block_ranges: Assertion `dwarf2_per_objfile->ranges.readin'
failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

LLVM r178533

thread-s...@googlecode.com

unread,
Jul 18, 2013, 12:24:35 PM7/18/13
to thread-s...@googlegroups.com
Updates:
Status: Invalid

Comment #4 on issue 12 by dvyu...@google.com: SEGV in pthread_create with
TSan
http://code.google.com/p/thread-sanitizer/issues/detail?id=12

gdb bugs do not belong here
Reply all
Reply to author
Forward
0 new messages