discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Causing a core dump in GNUstep program


From: David Chisnall
Subject: Re: Causing a core dump in GNUstep program
Date: Thu, 28 Aug 2014 10:32:59 +0100

On 28 Aug 2014, at 00:59, Gregory Casamento <greg.casamento@gmail.com> wrote:

> You could dereference a nil pointer on purpose.  Make sure you set lots 
> properly to allow it to produce a core file. 

This is a bad idea.  The compiler will often remove this code, because it knows 
that it has undefined behaviour and so it's free to do anything it wants 
(including just removing the load / store operation).

The simplest thing to do is __builtin_trap(), which (with gcc or clang) will 
expand to an illegal instruction (ud2 on x86), which will cause an illegal 
instruction trap and then an illegal instruction signal to be delivered to the 
process.  The default action on receiving SIGILL is to drop core.

David

-- Sent from my Cray X1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]