Here are the exact steps carried out, resulting in the violation "mudflap violation 1 (unregister)", despite this program being absolutely correct. Note also that I have confirmed the identical problem with the gcc trunk -- version 4.2.0 (20060729) as well:
$ cat test.c #include <stdio.h> #include <pthread.h> void* test_thread(void* arg) { printf("\nHello from thread!"); pthread_exit(NULL); } int main() { #ifdef _REENTRANT printf("\nYes, _REENTRANT is defined"); #endif pthread_t thread; int arg = 0; pthread_create(&thread, NULL, test_thread, (void*)arg); pthread_exit(NULL); return 0; } $ gcc -g -fmudflapth -pthread test.c -lmudflapth $ ./a.out ******* mudflap violation 1 (unregister): time=1154562440.431557 ptr=0x67d4e0 size=0 pc=0x6273e9 /usr/lib/libmudflapth.so.0(__mf_unregister+0x49) [0x6273e9] /usr/lib/libmudflapth.so.0(__real_free+0xae) [0x62833e] /lib/libdl.so.2 [0xa7051a] number of nearby objects: 0 Yes, _REENTRANT is defined Hello from thread! -- Summary: A most simple multithreaded program (practically any multithreaded one) causes mudflap violation Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libmudflap AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vesselinpeev at hotmail dot com GCC host triplet: 386 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28578