malloc crash

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Oct 26 09:28:28 GMT 2021


On Oct 26 01:59, Mark Geisert wrote:
> Takashi Yano wrote:
> > I tried the following patch, and confirmed that the issue has
> > been disappeared. I do not notice any other problems so far
> > with this patch.
> > 
> > diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
> > index 6f4723bb0..0d541ec14 100644
> > --- a/winsup/cygwin/dcrt0.cc
> > +++ b/winsup/cygwin/dcrt0.cc
> > @@ -773,6 +773,10 @@ dll_crt0_0 ()
> >     do_global_ctors (&__CTOR_LIST__, 1);
> 
>       ^^^^^^^^^^^^^^^
> 
> >     cygthread::init ();
> > +  /* malloc_init() has been moved from dll_crt0_1() to here so that
> > +     malloc() can be called in fixup_after_exec(). */
> > +  malloc_init ();
> > +
> >     if (!child_proc_info)
> >       {
> >         setup_cygheap ();
> > @@ -857,7 +861,7 @@ dll_crt0_1 (void *)
> >        on a functioning malloc and it's possible that the user's program may
> >        have overridden malloc.  We only know about that at this stage,
> >        unfortunately. */
> > -  malloc_init ();
> > +  /* malloc_init() has been moved to dll_crt0_0(). */
> >     user_shared->initialize ();
> >   #ifdef CYGHEAP_DEBUG
> > 
> > 
> > Where is the "constructor chain" you mentioned?
> 
> See above.  Try moving your new lines above the call to do_global_ctors().
> Also note the comment just above the original location of those lines..
> you're now ignoring what the comment warns about.

So we need malloc_init_0 and malloc_init_1, right? :)


Corinna


More information about the Cygwin-developers mailing list