Bug 31957 - mcheck failed in multi-thread malloc/free test
Summary: mcheck failed in multi-thread malloc/free test
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: malloc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-05 14:33 UTC by Miguel Martín
Modified: 2024-07-05 15:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
reproducer (1.23 KB, text/x-csrc)
2024-07-05 14:33 UTC, Miguel Martín
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miguel Martín 2024-07-05 14:33:40 UTC
Created attachment 15602 [details]
reproducer

This problem was detected while creating new tests to enhance aligned_alloc/calloc/malloc test coverage (https://patchwork.sourceware.org/project/glibc/list/?series=35824)

A simplified reproducer is attached.

gcc -o threaded-malloc-free threaded-malloc-free.c ;
./threaded-malloc-free; echo $?
0

valgrind --tool=memcheck ./threaded-malloc-free 
==3433528== Memcheck, a memory error detector
==3433528== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==3433528== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==3433528== Command: ./threaded-malloc-free
==3433528== 
==3433528== 
==3433528== HEAP SUMMARY:
==3433528==     in use at exit: 0 bytes in 0 blocks
==3433528==   total heap usage: 131,147 allocs, 131,147 frees, 134,242,488 bytes allocated
==3433528== 
==3433528== All heap blocks were freed -- no leaks are possible
==3433528== 
==3433528== For lists of detected and suppressed errors, rerun with: -s
==3433528== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

gcc -o threaded-malloc-free threaded-malloc-free.c -lmcheck
LD_PRELOAD=/lib64/libc_malloc_debug.so.0 ./threaded-malloc-free; echo $?
memory clobbered before allocated block
memory clobbered before allocated block
Aborted (core dumped)
134
Comment 1 Florian Weimer 2024-07-05 15:34:46 UTC
Looks like a de-facto duplicate of bug 9939 to me. We don't do the problematic hook updates anymore, but there's still no lock protecting the allocation list in malloc/mcheck-impl.c.