Description of problem: segfaults can occur with MEMCHECK_ALLOC_=3 enabled. This was reported and fixed upstream at http://sourceware.org/bugzilla/show_bug.cgi?id=10282 http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cc49a5a8837be1f9307b167d9bf4399798a847c9 Version-Release number of selected component (if applicable): glibc-2.5-49 How reproducible: every time Steps to Reproduce: 1. cat malloc_test.c #include <stdlib.h> #include <unistd.h> int main(void) { #pragma omp parallel num_threads(256) while (1) { void *ptr = malloc(rand() % 65536); usleep((rand() % 100) * 100); free(ptr); usleep((rand() % 100) * 100); } return 0; } 2. gcc -fopenmp -g -o malloc_check malloc_check.c 3. MALLOC_CHECK_=3 ./malloc_test Actual results: malloc: using debugging hooks *** glibc detected *** ./malloc_test: free(): invalid pointer: 0x00000000043e9c90 *** Expected results: no segfaults Additional info:
(Oops, MEMCHECK_ALLOC_ should have been MALLOC_CHECK_)
Created attachment 408960 [details] malloc check patch The upstream patch applied cleanly except for some line number fuzziness. Attached is a slightly modified patch to correct the line numbers.
also filled under http://bugs.centos.org/view.php?id=4370
*** Bug 633841 has been marked as a duplicate of this bug. ***
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: Due to a race in the 'free()' function, enabling 'MALLOC_CHECK_' could cause a segmentation fault. This update adds proper locking in the 'free()' function to prevent the aforementioned segmentation fault.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0109.html