LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-08-2014, 12:53 PM   #1
5883
Member
 
Registered: Aug 2004
Posts: 173

Rep: Reputation: 0
A strange core dump shows functions can only happen in another process


we have an issue like this, app1 and app2 both use shared_lib.so.

overnight the apps crashed and generated a code dump.

the core dump is from app2, when we load it to gdb, the stack shows functions can only be called from app1.
so we are totally lost, have you seen such things before ?

Thanks very much !
 
Old 07-08-2014, 01:33 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Are you absolutely certain those functions don't exist in the shared library?
I think you can use nm to list the symbols of the shared library
 
Old 07-09-2014, 04:06 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
> the core dump is from app2, when we load it to gdb, the stack shows functions can only be called from app1.

Guess it means: functions that are not supposed to be called from app2...
 
Old 07-09-2014, 06:42 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Many bugs in a program can corrupt the stack so that gdb displays an incorrect back trace. Sometimes gdb just displays an incorrect backtrace without any stack corruption.
So you need to consider both the possibility that gdb is showing an incorrect backtrace and the possibility that functions are called by app2 that you did not expect to be called by app2.
Take a closer look at what gdb is showing you and figure out what makes more sense.
The raw contents of registers and memory (including the stack) are correctly shown by gdb. So you can see what was really there at the moment of the crash. Higher interpretations of that data (such as a backtrace or the contents of named local variables) shown by gdb must be looked at with some amount of distrust.
 
Old 07-09-2014, 12:24 PM   #5
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
yes this is what i mean

Quote:
Originally Posted by NevemTeve View Post
> the core dump is from app2, when we load it to gdb, the stack shows functions can only be called from app1.

Guess it means: functions that are not supposed to be called from app2...
 
Old 07-09-2014, 12:26 PM   #6
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
actually the back trace shows at the line like this,

func()
{
............
{
static DWORD var = 0;
var++;
}
}

wondering if static variable in shared lib could have troubles.


Quote:
Originally Posted by johnsfine View Post
Many bugs in a program can corrupt the stack so that gdb displays an incorrect back trace. Sometimes gdb just displays an incorrect backtrace without any stack corruption.
So you need to consider both the possibility that gdb is showing an incorrect backtrace and the possibility that functions are called by app2 that you did not expect to be called by app2.
Take a closer look at what gdb is showing you and figure out what makes more sense.
The raw contents of registers and memory (including the stack) are correctly shown by gdb. So you can see what was really there at the moment of the crash. Higher interpretations of that data (such as a backtrace or the contents of named local variables) shown by gdb must be looked at with some amount of distrust.
 
Old 07-09-2014, 01:06 PM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by 5883 View Post
wondering if static variable in shared lib could have troubles.
What kind of "troubles"?

I'm nearly sure static variables in .so libraries are NOT shared across executable, even when the rest of the .so is shared.

In C++ (not sure about C) function static variables can have run time execution, even when the function containing them does not get executed. But that doesn't seem like it would be the case for the example you gave.

You should look at the entire call stack to see if it makes sense.
 
Old 07-09-2014, 11:24 PM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
What does command 'backtrace' say?
 
Old 07-10-2014, 10:48 AM   #9
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
warning: core file may not match specified executable file.
[New LWP 3387]
[New LWP 3307]
[New LWP 3818]
[New LWP 3247]
[New LWP 3313]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabi/libthread_db.so.1".
Core was generated by `'.
Program terminated with signal 11, Segmentation fault.
#0 0x403872e8 in ?? () from /opt/ultra/lib/libsub_system.so.1
(gdb) where
#0 0x403872e8 in ?? () from /opt/ultra/lib/libsub_system.so.1
#1 0x403761c8 in TimerManager::ProcessMessage(void*) ()
from /opt/ultra/lib/libsub_system.so.1
#2 0x000a6928 in ?? ()
#3 0x000a6928 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

don't understand why no complete call stack.

Quote:
Originally Posted by NevemTeve View Post
What does command 'backtrace' say?

Last edited by 5883; 07-10-2014 at 10:51 AM.
 
Old 07-10-2014, 10:49 AM   #10
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
http://stackoverflow.com/questions/2...n-program-exit

not exact the same, but ...

Quote:
Originally Posted by johnsfine View Post
What kind of "troubles"?

I'm nearly sure static variables in .so libraries are NOT shared across executable, even when the rest of the .so is shared.

In C++ (not sure about C) function static variables can have run time execution, even when the function containing them does not get executed. But that doesn't seem like it would be the case for the example you gave.

You should look at the entire call stack to see if it makes sense.
 
Old 07-10-2014, 11:20 AM   #11
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
warning: core file may not match specified executable file.
That's a clue. What command are you passing to gdb?
 
Old 07-10-2014, 12:47 PM   #12
5883
Member
 
Registered: Aug 2004
Posts: 173

Original Poster
Rep: Reputation: 0
just as normal,
gdb image_name core_filename

Quote:
Originally Posted by smeezekitty View Post
That's a clue. What command are you passing to gdb?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Process crashes and does not dump core traene Programming 5 03-09-2024 03:28 AM
Unable to get a core-dump of a child process on Linux 2.6.5-7.316-smp #1 SMP system ravisan Linux - General 2 07-28-2023 11:09 AM
Kernel Core dump shows invalid backtrace saran1987 Linux - Newbie 1 03-03-2014 07:29 AM
child process does not core dump sinu_nayak2001 Linux - Newbie 1 07-27-2011 10:18 AM
Core dump issues. Program crashes but does not generate core dump file sabeel_ansari Programming 1 10-07-2009 04:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration