malloc crash

Ken Brown kbrown@cornell.edu
Tue Oct 26 14:32:07 GMT 2021


On 10/26/2021 5:24 AM, Corinna Vinschen wrote:
> On Oct 25 18:02, Ken Brown wrote:
>> Or does the fifo_reader thread call a malloc function before the main thread
>> has called malloc_init()?  This would presumably cause __malloc_lock() to
>> fail, but there's no error check.
> 
> That sounds more likely.  In theory this shouldn't have much influence,
> though.  First of all, all fixup calls are running in a single thread,
> so there's no serialization required(*), and the malloc_init call
> doesn't set up the malloc arena, it just initializes the muto and checks
> for user space provided malloc calls, which is not a problem in this
> scenario.
> 
> (*) unless multiple threads are started during fixup and some of these
>      threads mallocate memory again...
> 
> Ken, is there a chance to tweak the fifo code to stop creating
> threads from inside fixup, and to defer the thread start to the first
> call in the process actually relying on the thread being started?

I can't think of any way to do that.  The thread is listening for various events 
that cause it to take action, so it has to always be running.  But I can 
probably tweak the code so that the thread doesn't have to call malloc early on.

It might take a while to get this right, and the bug has existed ever since I 
overhauled the fifo code.  So I don't think you have to hold up releasing 3.3.0 
while I work on this.

Ken


More information about the Cygwin-developers mailing list