- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a problem - it is necessary to simulate a segmentation fault in the code in order to make the application crash, however, it does not crash when compiled with Intel Compiler :-)
Code like this:
int* p = 0;
*p = 10;
or this:
puts((const char*)(void*)((unsigned long long)-1));
crashes the application perfectly when it is compiled with MS compiler, however, no crash occurs and some sort of exception is generated when it is compiled with Intel.
How to knowingly make the Intel-compiled code crash in any manner ?
I have a problem - it is necessary to simulate a segmentation fault in the code in order to make the application crash, however, it does not crash when compiled with Intel Compiler :-)
Code like this:
int* p = 0;
*p = 10;
or this:
puts((const char*)(void*)((unsigned long long)-1));
crashes the application perfectly when it is compiled with MS compiler, however, no crash occurs and some sort of exception is generated when it is compiled with Intel.
How to knowingly make the Intel-compiled code crash in any manner ?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler optimizations may have seen that your program did not use *p and thus removed it.
Try this:
int* p_CrashTheProgram = 0;
__declspec(noinline)
void CrashTheProgram(int info=0)
{
*p_CrashTheProgram = info;)
}
Jim Dempsey
Try this:
int* p_CrashTheProgram = 0;
__declspec(noinline)
void CrashTheProgram(int info=0)
{
*p_CrashTheProgram = info;)
}
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jim,
I have checked - my code is not optimized out, it works. I have also tried your solution out with same result - no crash, some exception generated (it is caught in catch (...) block).
I have checked - my code is not optimized out, it works. I have also tried your solution out with same result - no crash, some exception generated (it is caught in catch (...) block).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your first post did not indicate you were using exception handling. With exception handling enabled, your program does "crash", but then "recovers" under an exception condition.
With exception handling enabled, it is your responsibility to add a "catch" for segmentation fault (in this case a write to write protected/or non-mapped memory).
Jim Dempsey
With exception handling enabled, it is your responsibility to add a "catch" for segmentation fault (in this case a write to write protected/or non-mapped memory).
Jim Dempsey
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page