mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [RFC] malloc + threads = memleak?
Date: Fri, 9 Feb 2018 10:00:26 -0500	[thread overview]
Message-ID: <20180209150026.GI1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <CADA+G1tvfRqOo2-Djy4VuCW=PXieGd4O8kYwYHhVErJHukMD-Q@mail.gmail.com>

On Fri, Feb 09, 2018 at 04:33:38PM +0200, Roman Yeryomin wrote:
> Hello!
> 
> I have a very easy reproducible memory leak here when using
> malloc/free in two threads.
> Attaching a simple test.
> thread() here is calling pthread_create():
> https://github.com/yeryomin/liba/blob/master/liba.c#L181
> 
> Do I misunderstand something or is it a bug?
> This can be avoided by wrapping malloc into locks but not sure if
> that's the fix you want...

I haven't looked at this in detail yet, but I suspect this is a known
issue that I thought was hard to hit, and that you've just found a
reliable way to reproduce. I'll investigate more in a bit. I think it
may turn out to be impossible to fix without either making malloc
noticably slower or overhauling the whole malloc implementation (which
is planned but I'm not ready to do yet).

Thanks for the report; this looks like it will be useful even if
disappointing.

Rich


      reply	other threads:[~2018-02-09 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 14:33 Roman Yeryomin
2018-02-09 15:00 ` Rich Felker [this message]

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=20180209150026.GI1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).