We help IT Professionals succeed at work.

Need help regarding SEGV

Deepti_vobilineni
on
190 Views
Last Modified: 2010-04-01
I am trying to handle SIGSEGV in my C++ program.
I wrote a signal handler that uses a different stack other than my program using SA_ONSTACK flag.
I want the core to be dumped when my program results in a SEGV. So i tried sending SEGV to the program using htop utility. My signal handler function is executed but I am not able to see any core dump.

What else I need to do so that I can get the core dump and how to set the path of the core dump file?
Also, I need to know if there is a way to access the core file in the program so that I can print its contents into the log file before exiting the program after it results in SEGV?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009

Commented:
To enable core dumps, do :

        ulimit -c

to see whether core dumps are enabled now. If they're not, then set the maximum size of the core dump to a value bigger than 0 (preferrably a lot bigger ;) ) :

        ulimit -c 10000

or :

        ulimit -c unlimited

Author

Commented:
My ulimit value for core file is already set to unlimited.

[root@InvadePRI ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
max nice                        (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 77824
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
max rt priority                 (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 77824
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Author

Commented:
[root@InvadePRI ~]# ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
max nice                        (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 77824
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
max rt priority                 (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 77824
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
CERTIFIED EXPERT
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2009

Commented:
May I ask why you gave a B grade ? That usually means that something was missing in the answer and/or that something is still unclear. If so, you don't have to close the question yet, and can ask for clarification where needed.

Author

Commented:
Sorry, I did not give any grade as such...This is the first time I am using this site and i am so happy to find a solution within no time...thnks 2 u for the reply...My doubt was answered promptly and I didnt know how u were assigned a B grade !!??
CERTIFIED EXPERT
Top Expert 2009

Commented:
No problem ;) I'm glad to be of assistance.

The grade is assigned when you close the question (you get the option to choose the grade). For more information on choosing the correct grade, see here :

        https://www.experts-exchange.com/help.jsp#hi97
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.