[PATCH v3 11/16] Print backtrace in a signal-safe manner
Chase Douglas
chase.douglas at canonical.com
Mon May 14 12:39:31 PDT 2012
On 05/10/2012 11:24 PM, Peter Hutterer wrote:
> On Mon, Apr 16, 2012 at 11:14:28AM -0700, Chase Douglas wrote:
>> Backtraces are often printed in signal context, such as when a segfault
>> occurs.
>>
>> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
>> ---
>> os/backtrace.c | 49 +++++++++++++++++++++++++++++--------------------
>> 1 files changed, 29 insertions(+), 20 deletions(-)
>>
>> diff --git a/os/backtrace.c b/os/backtrace.c
>> index 81348f4..d41c3f3 100644
>> --- a/os/backtrace.c
>> +++ b/os/backtrace.c
>> @@ -45,29 +45,37 @@ xorg_backtrace(void)
>> int size, i;
>> Dl_info info;
>>
>> - ErrorF("\n");
>> - ErrorF("Backtrace:\n");
>> + ErrorSigSafe("\n");
>> + ErrorSigSafe("Backtrace:\n");
>> size = backtrace(array, 64);
>
> is backtrace() itself signal-safe? the man pages suggest not yet it appears
> to have worked well so far.
I don't know. I think it is on some platforms.
I think the loss of functionality here would be quite a burden. I
propose assuming it is signal safe, and undoing things if we find it not
to be the case. Running Xorg under valgrind and causing xorg_backtrace()
to fire does not emit any warnings on my machine, unlike *printf.
> This commit should also be moved forward - it should go in before the
> BUG_WARN updates
Ok.
-- Chase
More information about the xorg-devel
mailing list