Visit The New, Modern Unix Linux Community

Collecting Shared Memory in core dump

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Collecting Shared Memory in core dump
# 1  
Collecting Shared Memory in core dump

I have an application which crashed while accessing a shared memory.
typedef struct
} LnxUserData;

LnxUserData *ptrLnxUserData;

fd = shm_open(shrSegName, O_CREAT|O_RDWR|O_EXCL, 0644);
if(fd == -1 && errno == EEXIST)
    fd = shm_open(shrSegName, O_CREAT|O_RDWR, 0644);
ptrLnxUserData = mmap(0, sizeof(LnxUserData), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

But in the core when I try to access the memory it gives me error

(gdb) p *ptrLnxUserData
Cannot access memory at address 0xeb80d050

This may be probably because core does not collect the shared memory details.
So when an application pointer which had address of the shared memory is accessed it is not able to access it inside core.

Is there any way or any dump setting through which shared memory or its details can also be collected in core?

Last edited by rupeshkp728; 06-29-2014 at 05:58 PM..
# 2  
Which OS and version you are using? I assume Linux since you mention gdb

The /proc/PID/coredump_filter file, available since Linux kernel 2.6.23 can be used to control which memory segments are written to the core dump file. Man core(5)
These 2 Users Gave Thanks to fpmurphy For This Post:
# 3  
Thanks Murphy for the info.
I am using SUSE Linux SLES x86_64.

I will check your suggestions.

Last edited by rupeshkp728; 06-27-2014 at 11:35 AM..
# 4  
I tried setting the filter value to 3f but it did not help.

Core man page mentions "Memory-mapped I/O pages such as frame buffer are never dumped, and virtual DSO pages are always dumped, regardless of the coredump_filter value."

And through mmap I think we are doing Memory-mapped I/O pages and so we are not getting the shared memory details in core.

---------- Post updated at 08:39 PM ---------- Previous update was at 02:19 AM ----------

Is there any way through which shared memory or its details can be collected in core and accessed?
What is the appropriate way to debug and root cause applications which cores at shared memory?
# 5  
Originally Posted by rupeshkp728
Is there any way through which shared memory or its details can be collected in core and accessed?
Core dump occur as default action of a few signals. The list is available with "man -s7 signal" on RedHat. You could install a signal handler to catch all those signals. It could then display what ever information you want.

One issue to watch for... You may be getting a core dump because you blew the stack. So you will need to use sigaltstack() to provide an alternate stack to use with your handler to guarantee that it can run.
This User Gave Thanks to Perderabo For This Post:
# 6  
From my reading of the man page for core, the process should be dumping the mmap()'d data, as that's a "file-backed shared mapping". IIRC, POSIX shared memory is implemented as a mmap()'d file. What's the contents of the file afterwards? IIRC it should be in "/var/run/shm" or "/dev/shm".

And what is the name you're passing to shm_open()? Make sure it doesn't have any "/" characters in it.

Good luck writing your own core-dump utility. That's not very easy at all and you almost certainly won't do as good a job of it as the Linux kernel coders have. You can try running gcore via system() in a signal handler, but be sure you don't return from your handler and all you do is kill your process with SIGKILL - if you return, your signal handler will just get called again.
This User Gave Thanks to achenle For This Post:
# 7  
My reading of the core man page suggests that by default a "file-backed shared mapping" will not be dumped.

The default value of coredump_filter is 0x3; this reflects traditional Linux behavior and means that only anonymous memory segments are dumped.
So if he has a recent kernel he can override this and get the region dumped. But that option will not exist on older kernels.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #280
Difficulty: Easy
CPU modes (also called processor modes, CPU states, CPU privilege levels and other names) are operating modes for the central processing unit of some computer architectures that place restrictions on the type and scope of operations that can be performed by certain processes being run by the CPU.
True or False?

10 More Discussions You Might Find Interesting

1. Solaris

core dump

Hi guys, just want to know which core file pattern is best to set for core dumps: 1) per-process file name pattern or 2) global file name pattern. I will really appreciate an explanation why the chosen one is better. Thanks a lot guys. (2 Replies)
Discussion started by: cjashu
2 Replies

2. Programming

Shared library with acces to shared memory.

Hello. I am new to this forum and I would like to ask for advice about low level POSIX programming. I have to implement a POSIX compliant C shared library. A file will have some variables and the shared library will have some functions which need those variables. There is one special... (5 Replies)
Discussion started by: iamjag
5 Replies

3. UNIX for Advanced & Expert Users

collecting memory usage by a process

Hi Guys, I work on a AIX environment and I'm trying to write a script where I can collect all the memory used by a process. Basically I'm executing the command 'ps -fu userid' to get all the process ids and then executing the 'ps v PID' to get all the memory allocated by PPID. My question is... (2 Replies)
Discussion started by: arizah
2 Replies

4. HP-UX

memory fault(core dump)

i am getting memory fault (core dump) in a C program i want to know which statement execution caused it. i tried following things $ gdb generalised_tapinread_mod HP gdb 5.4.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x. Copyright 1986 - 2001 Free Software Foundation, Inc.... (2 Replies)
Discussion started by: junaid.nehvi
2 Replies

5. Programming

core dump

how to view core dumped file using gdb and how to extract information from the coredumped file.can we get similar information from the other utilites like strace or ptrace. (2 Replies)
Discussion started by: Manabhanjan
2 Replies

6. UNIX for Dummies Questions & Answers

Core dump in HP-UX..

Hi All I am new for this forum. I have a core file by using gdb and bt cmd I got the function name but I want to the exact cause of the core dump because of I can not reproduse the binary so if any one know the cmd plz plz plz let me know. (0 Replies)
Discussion started by: gyanusoni
0 Replies

7. UNIX for Advanced & Expert Users

Shared memory shortage but lots of unused memory

I am running HP-UX B.11.11. I'm increasing a parameter for a database engine so that it uses more memory to buffer the disk drive (to speed up performance). I have over 5GB of memory not being used. But when I try to start the DB with the increased buffer parameter I get told. "Not... (1 Reply)
Discussion started by: cjcamaro
1 Replies

8. UNIX for Dummies Questions & Answers

core dump

Hi , Working on AIX 4.3. An internal error from my apps engine suddenly causes the engine to die. During this time i do notice a core file being dumped in the directory from where I try to re-start my engine. Q is how does one read this core file, or I should say 'what is this core file'? thnx (2 Replies)
Discussion started by: buRst
2 Replies

9. UNIX for Dummies Questions & Answers

core dump

does any one have read a core dump? is there any reader for that? or may i know what is the use of that core which takes sometimes memory in GBs? :) (6 Replies)
Discussion started by: sskb
6 Replies

10. UNIX for Dummies Questions & Answers

help, what is the difference between core dump and panic dump?

help, what is the difference between core dump and panic dump? (1 Reply)
Discussion started by: aileen
1 Replies

Featured Tech Videos