This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Avoid deadlock in malloc on backtrace
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>, Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha at sourceware dot org, carlos at redhat dot com
- Date: Tue, 24 Feb 2015 09:51:57 -0800
- Subject: Re: [PATCH] Avoid deadlock in malloc on backtrace
- Authentication-results: sourceware.org; auth=none
- References: <20150224100249 dot GA31871 at spoyarek dot pnq dot redhat dot com> <54EC52E6 dot 5010905 at redhat dot com> <20150224115158 dot GH23807 at spoyarek dot pnq dot redhat dot com>
On 02/24/2015 03:51 AM, Siddhesh Poyarekar wrote:
dynamically loading the library requires malloc
How about dynamically linking _Unwind_Backtrace etc. at startup, rather
than doing it lazily after heap memory may been corrupted and one really
needs the backtrace?
It is news to me that 'backtrace' can call 'malloc' the first time that
one uses 'backtrace'. Now that I know this, I suppose I should modify
Emacs to do a no-op call to 'backtrace' first thing, before Emacs does
anything important. That way, when Emacs really needs to call
'backtrace' due to a bad pointer or whatever, we'll have more confidence
that the call to 'backtrace' will actually work.
But really, we shouldn't have to modify applications to work around this
problem, and the problem should be fixed in glibc. 'backtrace'
shouldn't require 'malloc' to work, as we want 'backtrace' to get a
backtrace as reliably as possible even when part of memory is corrupted.