c - Valgrind: Deliberately cause segfault -
This is a crazy hack , but I deliberately trying to cause a segfault specifically Indicate in the execution, Valgrind will give me a stack trace.
If there is a better way of doing this, please let me know, but I still want to know how deliberaly is a segfault cause, and why my attempt does not work.
This is my failed attempt:
tall * ptr = (long *) 0xF0000000; Ptr = 10;
I thought valgrind should at least choose it as an invalid writing, even if it is not a division violation. Valgrind does not say anything about it.
Any ideas why?
Edit
Responses were accepted, but I still have some up-votes
< Div class = "post-text" itemprop = "text">
Do you have a *
similar to * ptr = 10
? You will not have a compilation.
If this happens then surely there will be no mistake, because you are just specifying a number. Dereferencing can happen.
Understanding the space in a signfult on your OS result, the following should do the trick:
Inline zero seg_fault (zero) {volatile int * p = Reinterpret_cast & lt ; Volatile int * & gt; (0); * P = 0x1337D00D; }
Comments
Post a Comment