On 09/05/2013 04:50 PM, Anthony Liguori wrote:
>> +    int *p = NULL;
>> +
>> +    *p = 0xDEADBEEF;
> 
> I won't repeat the questions from Paolo and Lazlo (I share their
> confusion) but will simply add that you cannot rely on NULL address
> accessing causing a SEGV.  Even with all the use of volatile in the
> world, there's no guarantee this is going to crash.

If you want to guarantee that a write would cause a SEGV, then you have
to use mmap(MAP_ANONYMOUS|MAP_PRIVATE) + mprotect(PROT_NONE) to get a
valid unwritable pointer that will reliably fault, rather than hoping
that NULL (or any other low-valued intptr_t cast to void*) is
sufficiently protected.  But I also echo the question: why is raise()
insufficient?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to