I was trying to see if SIGSEGV signal hander could help to deal with unhandled exception of C++, I experiment it: $ g++ -g h.cpp -rdynamic && ./a.out terminate called after throwing an instance of ‘int’ Aborted (Core dump) Well, the program doesn’t print crash call stack back trace as I expected. My question is: As long as it terminates,
Tag: segmentation-fault
Catching SIGSEGV when triggered by corrupt stack
I’ve been working on some buggy code and wanted to install a SIGSEGV handler to get more information about the crash. However, I noticed that my handler is not invoked. I’ve been looking for a reason and it seems it has to do with a corrupt stack pointer value (it’s not getting masked for sure). Here’s some proof-of-concept code I
Segmentation fault while trying to return a pointer to object from a method
g++ throw me ‘segmentation fault’ while I’m trying to return an object of a classB from a method of a classA. I don’t know how to fix this error, if anybody can tell me why this error happens, I would be grateful. So… here is the code: classA.h classA.cpp classB.h classB.cpp main.cpp Makefile SRC = src INC = include OBJ
Reading 2 byte at a time from a binary file
I have an elf file that called example. I wrote following code which it’s read the content of the example file in the binary mode and then I wanted to save their content in another file called example.binary. But when I run the following program it shows me a segmentation fault. What’s wrong with this program? I can’t find out
C segmentation fault on linux with strncmp
This works (‘Y’ must be single quotes): This gives segmentation fault: strncmp must be going off the deep end but not sure why since I’m passing a casted toupper() as (char *). Without the casting, same error. FYI user_input() is (N.B. vars are global): Thank you. Answer The return value of toupper is another character, not a pointer to a
How to write a swap function in assembly?
I’ve been trying to figure out how to write a x86 GAS swap function for my program. I know its easier to do xchg or just write it C, but I want to be able to write it out anyways. On my 1st midterm we were given this as as swap function: but I receive a segmentation fault when running
c program works on windows take segmantation fault on linux
I wrote some c code on codeblocks. It works perfectly fine on Windows but gave segmantation fault on Linux. Why ? This is main. I used 3 libraries and opencells method calls a recursive method. Answer Change: (int) to (int*) Because sizeof(int) and sizeof(int*) maybe different, so your program maybe crashed when access the not allocated memory.
Segmentation fault with ucontext makecontext on OS X 10.10
I run my code in OS X 10.10 with gcc. I am trying to implement a usercontext library. If I comment out thread_create( &t2, thr2, NULL);, the code will produce desired effect. I have no idea why a line related to t2 will lead to segmentation fault of t1. Author’s Notes I happily work on implementing a usercontext library after
Why does my assembly program give segfault?
I have the following piece of code that I have to debug: After compiling and running that code I obtain a segmentation fault error, it seems that something goes wrong after the 5th line. My linux asm knowledge is very basic, any hints or ideas about what is exactly going wrong and how to fix it? This piece of code
confusing segmentation fault involving ldap_url_parse function from openldap library
On a CentOS 6.6 server the following code compiles (with gcc version 4.4.7 or with clang version 3.4.2) without incident but results in a segmentation fault when run: However if I modify it to remove the string declaration, like so: then it runs without incident as well. On my Mac OS X 10.10.3 (Yosemite) both versions (with and without the