public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-developers@cygwin.com
Subject: Re: malloc crash
Date: Tue, 26 Oct 2021 18:26:39 +0900	[thread overview]
Message-ID: <20211026182639.92f6f9de086ec35f41deef88@nifty.ne.jp> (raw)
In-Reply-To: <b8ea3fc0-0cb5-fa84-a087-112d6b6631ae@maxrnd.com>

On Tue, 26 Oct 2021 01:59:36 -0700
Mark Geisert wrote:
> Takashi Yano wrote:
> > On Tue, 26 Oct 2021 01:30:13 -0700
> > Mark Geisert wrote:
> >> Apologies; this was many months ago.  What I did try was moving the malloc_init()
> >> to before running the constructor chain, as Takashi suggested.  That is what gave
> >> me more problems.  I don't recall what they were, but I reverted that attempt.
> >>
> >> The "future malloc" build of Cygwin I'm running doesn't exhibit Ken's issue, as
> >> far as I can tell.  It has a specific fix to avoid the scenario I've been talking
> >> about here, but I don't want to take us down that path unless we're sure Ken's
> >> hitting that same scenario.
> > 
> > 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.

I have just tried moving malloc_init() before do_global_ctors(),
however, I do not encountered any problems.

I do not understand what "user's program may have overridden malloc"
means...

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

  reply	other threads:[~2021-10-26  9:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-24 21:46 Ken Brown
2021-10-25  8:56 ` Takashi Yano
2021-10-25 13:37   ` Ken Brown
2021-10-25  8:59 ` Corinna Vinschen
2021-10-25 12:35   ` Ken Brown
2021-10-25 15:39     ` Corinna Vinschen
2021-10-25 21:29       ` Mark Geisert
2021-10-25 22:02         ` Ken Brown
2021-10-25 23:36           ` Mark Geisert
2021-10-26  0:18             ` Takashi Yano
2021-10-26  0:54               ` Mark Geisert
2021-10-26  8:30                 ` Mark Geisert
2021-10-26  8:52                   ` Takashi Yano
2021-10-26  8:59                     ` Mark Geisert
2021-10-26  9:26                       ` Takashi Yano [this message]
2021-10-26  9:31                         ` Corinna Vinschen
2021-10-26  9:28                       ` Corinna Vinschen
2021-10-26  9:27                 ` Corinna Vinschen
2021-10-26  9:24           ` Corinna Vinschen
2021-10-26 14:32             ` Ken Brown
2021-10-26 16:03               ` Corinna Vinschen
2021-10-26 16:36                 ` Ken Brown
2021-10-26 16:49                   ` Corinna Vinschen
2021-10-26 17:10                     ` Ken Brown
2021-10-27  0:44                     ` Takashi Yano
2021-10-27  9:01                       ` Corinna Vinschen
2021-10-26 16:44                 ` Takashi Yano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211026182639.92f6f9de086ec35f41deef88@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin-developers@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).