Linux callas 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:35:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux valgrind -v --tool=drd --read-var-info=yes ./a.out ==10376== drd, a thread error detector ==10376== Copyright (C) 2006-2012, and GNU GPL'd, by Bart Van Assche. ==10376== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info ==10376== Command: ./a.out ==10376== --10376-- Valgrind options: --10376-- -v --10376-- --tool=drd --10376-- --read-var-info=yes --10376-- Contents of /proc/version: --10376-- Linux version 3.8.0-19-generic (buildd@allspice) (gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) ) #30-Ubuntu SMP Wed May 1 16:35:23 UTC 2013 --10376-- Arch and hwcaps: AMD64, amd64-cx16-rdtscp-sse3-avx --10376-- Page sizes: currently 4096, max supported 4096 --10376-- Valgrind library directory: /tmp/lib/valgrind --10376-- Reading syms from /tmp/a.out --10376-- Reading syms from /lib/x86_64-linux-gnu/ld-2.17.so --10376-- Considering /lib/x86_64-linux-gnu/ld-2.17.so .. --10376-- .. CRC mismatch (computed 0e805c9a wanted d5b108bd) --10376-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.17.so .. --10376-- .. CRC is valid --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- warning: addVar: unknown size (loadcmds) --10376-- Reading syms from /tmp/lib/valgrind/drd-amd64-linux --10376-- object doesn't have a dynamic symbol table --10376-- warning: addVar: unknown size (ips) --10376-- Scheduler: using generic scheduler lock implementation. --10376-- Reading suppressions file: /tmp/lib/valgrind/default.supp ==10376== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-10376-by-kristian-on-??? ==10376== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-10376-by-kristian-on-??? ==10376== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-10376-by-kristian-on-??? ==10376== ==10376== TO CONTROL THIS PROCESS USING vgdb (which you probably ==10376== don't want to do, unless you know exactly what you're doing, ==10376== or are doing some strange experiment): ==10376== /tmp/lib/valgrind/../../bin/vgdb --pid=10376 ...command... ==10376== ==10376== TO DEBUG THIS PROCESS USING GDB: start GDB like this ==10376== /path/to/gdb ./a.out ==10376== and then give GDB the following command ==10376== target remote | /tmp/lib/valgrind/../../bin/vgdb --pid=10376 ==10376== --pid is optional if only one valgrind process is running ==10376== --10376-- Reading syms from /tmp/lib/valgrind/vgpreload_core-amd64-linux.so --10376-- Reading syms from /tmp/lib/valgrind/vgpreload_drd-amd64-linux.so --10376-- REDIR: 0x4018f40 (strlen) redirected to 0x4c3c2c0 (strlen) --10376-- Reading syms from /lib/x86_64-linux-gnu/libpthread-2.17.so --10376-- Considering /lib/x86_64-linux-gnu/libpthread-2.17.so .. --10376-- .. CRC mismatch (computed da6bb310 wanted d2233b1f) --10376-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libpthread-2.17.so .. --10376-- .. CRC is valid ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e49240 (pthread_create@@GLIB) W-> (0000.0) 0x04c2f080 pthread_create@* --10376-- new: 0x04e49240 (pthread_create@@GLIB) W-> (0000.0) 0x04c2ed90 pthread_create ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4c9e0 (pthread_cond_init@@G) W-> (0000.0) 0x04c32cf0 pthread_cond_init@* --10376-- new: 0x04e4c9e0 (pthread_cond_init@@G) W-> (0000.0) 0x04c32b70 pthread_cond_init ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4ca60 (pthread_cond_destroy) W-> (0000.0) 0x04c33170 pthread_cond_destroy@* --10376-- new: 0x04e4ca60 (pthread_cond_destroy) W-> (0000.0) 0x04c32ff0 pthread_cond_destroy ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4cbe0 (pthread_cond_wait@@G) W-> (0000.0) 0x04c33600 pthread_cond_wait@* --10376-- new: 0x04e4cbe0 (pthread_cond_wait@@G) W-> (0000.0) 0x04c33470 pthread_cond_wait ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4cf20 (pthread_cond_timedwa) W-> (0000.0) 0x04c33ac0 pthread_cond_timedwait@* --10376-- new: 0x04e4cf20 (pthread_cond_timedwa) W-> (0000.0) 0x04c33920 pthread_cond_timedwait ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d4a0 (pthread_cond_signal@) W-> (0000.0) 0x04c33f80 pthread_cond_signal@* --10376-- new: 0x04e4d4a0 (pthread_cond_signal@) W-> (0000.0) 0x04c33e00 pthread_cond_signal ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d580 (pthread_cond_broadca) W-> (0000.0) 0x04c34400 pthread_cond_broadcast@* --10376-- new: 0x04e4d580 (pthread_cond_broadca) W-> (0000.0) 0x04c34280 pthread_cond_broadcast ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d6c0 (pthread_cond_init@GL) W-> (0000.0) 0x04c32cf0 pthread_cond_init@* --10376-- new: 0x04e4d6c0 (pthread_cond_init@GL) W-> (0000.0) 0x04c32b70 pthread_cond_init ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d6f0 (pthread_cond_destroy) W-> (0000.0) 0x04c33170 pthread_cond_destroy@* --10376-- new: 0x04e4d6f0 (pthread_cond_destroy) W-> (0000.0) 0x04c32ff0 pthread_cond_destroy ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d710 (pthread_cond_wait@GL) W-> (0000.0) 0x04c33600 pthread_cond_wait@* --10376-- new: 0x04e4d710 (pthread_cond_wait@GL) W-> (0000.0) 0x04c33470 pthread_cond_wait ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d7a0 (pthread_cond_timedwa) W-> (0000.0) 0x04c33ac0 pthread_cond_timedwait@* --10376-- new: 0x04e4d7a0 (pthread_cond_timedwa) W-> (0000.0) 0x04c33920 pthread_cond_timedwait ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d850 (pthread_cond_signal@) W-> (0000.0) 0x04c33f80 pthread_cond_signal@* --10376-- new: 0x04e4d850 (pthread_cond_signal@) W-> (0000.0) 0x04c33e00 pthread_cond_signal ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4d8d0 (pthread_cond_broadca) W-> (0000.0) 0x04c34400 pthread_cond_broadcast@* --10376-- new: 0x04e4d8d0 (pthread_cond_broadca) W-> (0000.0) 0x04c34280 pthread_cond_broadcast ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4da30 (pthread_spin_init ) W-> (0000.0) 0x04c34700 pthread_spin_init --10376-- new: 0x04e4da30 (pthread_spin_init ) W-> (0000.0) 0x04c35930 pthread_spin_unlock ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4da30 (pthread_spin_init ) W-> (0000.0) 0x04c34700 pthread_spin_init --10376-- new: 0x04e4da30 (pthread_spin_init ) W-> (0000.0) 0x04c35930 pthread_spin_unlock ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4e530 (sem_init@@GLIBC_2.2.) W-> (0000.0) 0x04c36d20 sem_init@* --10376-- new: 0x04e4e530 (sem_init@@GLIBC_2.2.) W-> (0000.0) 0x04c36b90 sem_init ==10376== WARNING: new redirection conflicts with existing -- ignoring it --10376-- old: 0x04e4e560 (sem_destroy@@GLIBC_2) W-> (0000.0) 0x04c371c0 sem_destroy@* --10376-- new: 0x04e4e560 (sem_destroy@@GLIBC_2) W-> (0000.0) 0x04c37040 sem_destroy --10376-- Reading syms from /lib/x86_64-linux-gnu/libc-2.17.so --10376-- Considering /lib/x86_64-linux-gnu/libc-2.17.so .. --10376-- .. CRC mismatch (computed 7a0d6b10 wanted 5a2fe04b) --10376-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.17.so .. --10376-- .. CRC is valid --10376-- REDIR: 0x50e7d20 (strnlen) redirected to 0x4a2570e (_vgnU_ifunc_wrapper) --10376-- REDIR: 0x4e49240 (pthread_create@@GLIBC_2.2.5) redirected to 0x4c2f080 (pthread_create@*) --10376-- REDIR: 0x4e4ae40 (pthread_mutex_init) redirected to 0x4c30ec0 (pthread_mutex_init) --10376-- REDIR: 0x50e2010 (calloc) redirected to 0x4c2ca0d (calloc) --10376-- REDIR: 0x4e4af90 (pthread_mutex_lock) redirected to 0x4c31880 (pthread_mutex_lock) --10376-- REDIR: 0x4e4c100 (pthread_mutex_unlock) redirected to 0x4c326c0 (pthread_mutex_unlock) --10376-- REDIR: 0x50e19b0 (free) redirected to 0x4c2d693 (free) --10376-- REDIR: 0x4e4af60 (pthread_mutex_destroy) redirected to 0x4c313d0 (pthread_mutex_destroy) ==10376== Thread 5: ==10376== Conflicting load by thread 5 at 0x0505d3e0 size 4 ==10376== at 0x4E4FCF0: close (syscall-template.S:81) ==10376== by 0x4007CB: thread (t.c:17) ==10376== by 0x4C2ED74: vgDrd_thread_wrapper (drd_pthread_intercepts.c:355) ==10376== by 0x4E48F8D: start_thread (pthread_create.c:311) ==10376== by 0x5157E1C: clone (clone.S:113) ==10376== Location 0x505d3e0 is 0 bytes inside global var "__pthread_multiple_threads" ==10376== declared at vars.c:38 ==10376== Other segment start (thread 1) ==10376== at 0x4C2F301: pthread_create@* (drd_pthread_intercepts.c:483) ==10376== by 0x4007FB: main (t.c:35) ==10376== Other segment end (thread 1) ==10376== at 0x5157DE1: clone (clone.S:83) ==10376== by 0x4E47F44: do_clone.constprop.4 (createthread.c:74) ==10376== by 0x4E4966D: pthread_create@@GLIBC_2.2.5 (createthread.c:244) ==10376== by 0x4C2F220: pthread_create@* (drd_pthread_intercepts.c:473) ==10376== by 0x4007FB: main (t.c:35) ==10376== --10376-- REDIR: 0x4e4a160 (pthread_join) redirected to 0x4c2f660 (pthread_join) ==10376== ==10376== ERROR SUMMARY: 21 errors from 1 contexts (suppressed: 279 from 25) ==10376== ==10376== 21 errors in context 1 of 1: ==10376== Conflicting load by thread 5 at 0x0505d3e0 size 4 ==10376== at 0x4E4FCF0: close (syscall-template.S:81) ==10376== by 0x4007CB: thread (t.c:17) ==10376== by 0x4C2ED74: vgDrd_thread_wrapper (drd_pthread_intercepts.c:355) ==10376== by 0x4E48F8D: start_thread (pthread_create.c:311) ==10376== by 0x5157E1C: clone (clone.S:113) ==10376== Location 0x505d3e0 is 0 bytes inside global var "__pthread_multiple_threads" ==10376== declared at vars.c:38 ==10376== --10376-- --10376-- used_suppression: 24 drd-ld /tmp/lib/valgrind/default.supp:584 --10376-- used_suppression: 255 drd-libpthread-pthread_create /tmp/lib/valgrind/default.supp:645 ==10376== ==10376== ERROR SUMMARY: 21 errors from 1 contexts (suppressed: 279 from 25) HERE IS THE CODE: ================ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <pthread.h> /* Happens with two threads also */ #define THREAD_COUNT 256 void* thread(void* x) { int fd; (void)x; /* Happens with any file, not just /dev/null */ fd = open("/dev/null", O_RDONLY); if (fd < 0) { fprintf(stderr, "Error\n"); return 0; } close(fd); return 0; } int main() { size_t i; int r; pthread_t threads[THREAD_COUNT]; for (i = 0; i < THREAD_COUNT; ++i) { r = pthread_create(&threads[i], 0, &thread, 0); if (r != 0) { fprintf(stderr, "Error\n"); return 0; } } for (i = 0; i < THREAD_COUNT; ++i) { r = pthread_join(threads[i], 0); if (r != 0) { fprintf(stderr, "Error\n"); return 0; } } return 0; } Reproducible: Always
Also happens with Valgrind 3.8.1 Also happens when compiling with GCC 4.8.1 Also happens on Linux Mint 14 I compile using: gcc -pthread -g3 t.c
Thanks for the report. Does r13511 help ?
Yes. Thanks for fixing it.