Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - memory fault (Core dumped): (9 Items)
   
memory fault (Core dumped)  
Hi,

How to do debug a "Memory fault (Core dumped)" error?

I have a script which throws this memory fault error whenever it executes the command "cd /". 

Can anyone give me some information about how I can debug and know what is going wrong?

Thanks
Sunil
Re: memory fault (Core dumped)  
Hi,

is it actually the 'cd' command that's faulting? 

And which version of QNX Neutrino are you using? 6.4.1? If so, you're lucky - you can take a look yourself right away, 
as all our binaries are now built with debug information. The debug info is stripped from from the binaries and stored 
in separate .sym files.

To debug...
- Make sure you have a .core file of the crash. To get one, 'dumper' must 
  be running on your target when the crash occurs.
- Check out the sources for 'cd' into a new QNX C project named 'cd' in the IDE.
  Use the repository location http://community.qnx.com/svn/repos/coreos_pub
  and your MyQNX user name and password. Don't build, just get the source.
- Download the symbol and mapping information for your target. Go to the URL
  http://www.qnx.com/download/group.html?programid=18770
  and download target-<your-platform>-debug-200905201802.tgz.
- Install the downloaded debug information as described.
- Copy the .core file into your 'cd' project directory.
- Create a new debug configuration of type 'C/C++ Postmortem debugger'
  Project should be 'cd', for the binary, select 
  ${QNX_TARGET}/<your-platform>/bin/cd
  When prompted for a Corefile, select the 'cd.core' you copied from the target.

-> The debug perspective should open, showing you where the fault occured.

Hope this helps,
- Thomas
Re: memory fault (Core dumped)  
Hi Thomas,

Thanks for the information about debuging core dump. I thought I should give some more information about my project (as 
it might make things a little more complicated or a little more interesting).

My project is running on QNX 6.4.1. The "cd /" command is part of a script. The script has a structure similar to what's
 below:

#########################################
# 1st cd command
cd /

rm /usr

# some more rm command

# 2nd cd command
cd /

#########################################

As you can see there are two cd command. Strangely, the 1st cd operation works fine but the second one is the trouble 
maker.

I did find a .core file being created and I used coreinfo to get its contents. I have attached a txt file with this core
 dump. I would really like to know how to read this dump file and what the various details mean.

In the mean while, I will try to use the debug perspective to get more info about my core dump

Thanks
Sunil
Attachment: Text CoreDumped.txt 902 bytes
Re: memory fault (Core dumped)  
Hi Sunil,

> I did find a .core file being created and I used coreinfo to get its contents.
> I have attached a txt file with this core dump. I would really like to know
> how to read this dump file and what the various details mean.

I collected and put together a bit of information about reading coreinfo output; you can find it here:
  http://thaupt-web.2.xpdev-hosted.com/core/coreinfo.html

Please let me know if anything is unclear or requires further explanation.

Regarding your issue: You do
  cd /
  rm /usr
  rm ...
  cd /

Some thoughts come to mind:
* Why are you cd'ing to '/' twice? Shouldn't you still be there?
* Are there any symbolic links or prefixes in the paths you remove 
   that somehow point back to '/' ?
* Do you maybe remove the shell, too? It shouldn't hurt, but who knows...

- Thomas
Re: memory fault (Core dumped)  
Hi Thomas,

Thanks for the link on corefiles. That is very useful.

About your questions:

***************************************
Some thoughts come to mind:
* Why are you cd'ing to '/' twice? Shouldn't you still be there?
* Are there any symbolic links or prefixes in the paths you remove 
   that somehow point back to '/' ?
* Do you maybe remove the shell, too? It shouldn't hurt, but who knows...

***************************************

* This was an older script (not developed originally by me) but I left the 2nd cd command in its place for no particular
 reason. If I remove the 2nd cd, then I dont see any isssues. But still I want to know what's going wrong.
* The rm cmd removes ldqnx.so which is linked to /proc/boot/libc.so. I'll see if anything depends on this and then get 
back to you.
* I dont remove shell. The folders that I remove do not contain the shell.

Thanks
Sunil

(PS: I was on vacation for few days, so I could not reply earlier)
Re: memory fault (Core dumped)  
Hey Sunil,

I think removing ldqnx.so isn't too good an idea. To say anything depended on it would seem quite an understatement to 
me -- in fact, /everything/ depends on that (as it's the standard c library)...  So you'd better take care to leave that
 on in place.

- Thomas
Re: memory fault (Core dumped)  
Hey Thomas,

I am sorry, the ldqnx file was not being removed (My mistake while reading the script).

I used the link that you provided to debug the core dump. Turns out that a memory fault happens when "sh" tries to 
access a particular memory. The error printed has "SIGNALLED-SIGSEGV ACCERR fltno=5" which means that sh did not have 
permission to access a particular memory region.

Now I have to find what in "cd /" command made sh access a memory region for which it does not have access. I do have a 
refaddr, now the difficult part is finding what this memory points to.

Will let u know how it goes.

Sunil
Re: memory fault (Core dumped)  
After some more debuging I have managed to find the root cause of the problem but not the solution.

Just before the "cd /" operation, there is remove cmd which tries to delete all the contents of a folder. This folder 
only contains few user defined DLLs but they are not linked to anything that sh or cd use. WHich means that deleting the
 contents of this folder should not really affect the "cd /" operation.

So I am suspecting some kind of file system corrruption as the root cause.

Can anybody help me solve this from here?

Sunil
Re: memory fault (Core dumped)  
Hi Sunil,

not knowing the memory region at all, it's a little bit hard to say from here...

Also it strikes me as kind of odd that mere unlinking (which the rm'ing effectively is) would cause some memory used by 
'sh' to become unreferencable.

It would be really helpful if you could post:
 - the shell's environment (output of 'set' command),
 - your script, and
 - the .core file

Regards,
- Thomas