From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [lttng-dev] RFC: Fix crash in dlerror()
Date: Tue, 11 Feb 2014 20:51:40 +0000 (UTC) [thread overview]
Message-ID: <1494953964.23233.1392151900002.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <52F9746F.5070302@mentor.com>
----- Original Message -----
> From: "Stefan Seefeld" <stefan_seefeld@mentor.com>
> To: "Mathieu Desnoyers" <mathieu.desnoyers at efficios.com>
> Cc: lttng-dev at lists.lttng.org
> Sent: Monday, February 10, 2014 7:53:03 PM
> Subject: Re: [lttng-dev] RFC: Fix crash in dlerror()
>
> Mathieu,
>
> after our follow-up discussion I agree to the proposed patch. A few
> details below...
Great!
>
> On 02/08/2014 05:22 PM, Mathieu Desnoyers wrote:
>
> > Interesting approach. Then I wonder if we couldn't simply lookup every
> > symbol
> > we're interested in whenever any of the overridden function is called and
> > we notice a NULL pointer, and provide a simplistic "static" allocator for
> > every function overridden.
> >
> > Please let me know if something like the attached patch works for you.
> > It seems more solid to cover all the cases, so that if the dlsym()
> > implementation
> > ever chooses to use other functions from the memory allocator, it will
> > still work.
>
> OK, agreed.
>
>
> > +static
> > +void *static_realloc(void *ptr, size_t size)
> > +{
> > + /* Don't free previous memory location */
> > + return static_calloc_aligned(1, size, 1);
> > +}
>
> The above of course also needs a memcpy operation, to preserve the
> original data.
OK, added.
>
> > + if (cur_alloc.malloc == NULL) {
> > fprintf(stderr, "mallocwrap: unable to find malloc\n");
> > - return NULL;
> > + abort();
> > }
>
> I'm actually not quite sure what behaviour I would prefer as a user. My
> library-author feeling tell me to not abort the process, but return an
> error condition (i.e., NULL) and let the caller take care of how to
> handle it.
> On the other hand, not finding malloc certainly is a critical error.
> And, this isn't a library in the proper sense, but a preloaded wrapper,
> so users can always re-run his apps without it.
> Hmm...
I'm tempted to go the shortcut route (abort()) since this is really just a
wrapper. I'm attaching an updated version, which fixes a couple of incorrect
handling of the realloc case for the static allocator. I did not add yet the
mmap() stuff, since it adds a bit of complexity to the patch, and I would be
tempted to keep things simple in -rc. I really doubt that real-life use-cases
will have error messages going beyond 4kB. And if it ever happens, we'll hit a
abort() within the wrapper, and it will be easy to fix. I'm tempted to leave
this without the mmap stuff for 2.4, so we don't add regressions late in the
cycle, is that OK with you ?
Thanks,
Mathieu
>
> Otherwise the patch looks good.
>
> Thanks,
> Stefan
>
>
> --
> Stefan Seefeld
> CodeSourcery / Mentor Graphics
> http://www.mentor.com/embedded-software/
>
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-lttng-ust-malloc.patch
Type: text/x-patch
Size: 9308 bytes
Desc: not available
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20140211/cda0f891/attachment-0001.bin>
next prev parent reply other threads:[~2014-02-11 20:51 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 21:50 Stefan Seefeld
2014-02-08 16:06 ` Mathieu Desnoyers
2014-02-08 16:53 ` Stefan Seefeld
2014-02-08 22:22 ` Mathieu Desnoyers
2014-02-09 16:28 ` Stefan Seefeld
2014-02-11 0:31 ` Mathieu Desnoyers
2014-02-11 0:53 ` Stefan Seefeld
2014-02-11 20:51 ` Mathieu Desnoyers [this message]
2014-02-11 20:55 ` Stefan Seefeld
2014-02-12 3:39 ` Mathieu Desnoyers
2014-02-12 14:35 ` Mathieu Desnoyers
2014-02-12 21:59 ` Mathieu Desnoyers
[not found] ` <52FCAA28.6020708@mentor.com>
[not found] ` <1026072798.24303.1392297452496.JavaMail.zimbra@efficios.com>
[not found] ` <52FCCCD2.9050302@mentor.com>
[not found] ` <610029715.24333.1392300717731.JavaMail.zimbra@efficios.com>
[not found] ` <1692042945.24342.1392301795996.JavaMail.zimbra@efficios.com>
[not found] ` <1119459836.24348.1392302831554.JavaMail.zimbra@efficios.com>
[not found] ` <52FCE732.9090508@mentor.com>
2014-02-13 16:40 ` Mathieu Desnoyers
2014-02-13 16:51 ` Woegerer, Paul
2014-02-13 18:52 ` Mathieu Desnoyers
2014-02-13 19:44 ` Woegerer, Paul
2014-02-13 22:06 ` Woegerer, Paul
2014-02-13 22:44 ` Stefan Seefeld
2014-02-14 6:59 ` Woegerer, Paul
2014-02-14 10:30 ` Alexander Monakov
2014-02-14 11:35 ` Woegerer, Paul
2014-02-14 11:54 ` Woegerer, Paul
2014-02-14 13:45 ` [lttng-dev] [PATCH] Force static_alloc setup to be written into memory Paul Woegerer
2014-02-14 14:08 ` Mathieu Desnoyers
2014-02-14 14:23 ` Alexander Monakov
2014-02-14 14:39 ` Woegerer, Paul
2014-02-14 14:46 ` Stefan Seefeld
2014-02-14 15:12 ` Mathieu Desnoyers
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=1494953964.23233.1392151900002.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.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