GC issue? List.pool overwritten by allocated object

Denis Feklushkin feklushkin.denis at gmail.com
Wed May 14 09:11:13 UTC 2025


On Wednesday, 14 May 2025 at 08:00:06 UTC, Denis Feklushkin wrote:

> But I don't understand why malloc() can give intersecting 
> allocations in this case. Any ideas?

The malloc function could either be thread-safe or thread-unsafe. 
Both are not reentrant:

Malloc operates on a global heap, and it's possible that two 
different invocations of malloc that happen at the same time, 
return the same memory block. (The 2nd malloc call should happen 
before an address of the chunk is fetched, but the chunk is not 
marked as unavailable). This violates the postcondition of 
malloc, so this implementation would not be re-entrant.

https://stackoverflow.com/a/3941563

Okay, I think the question can be considered closed


More information about the Digitalmars-d mailing list