LinuxQuestions.org
Visit Jeremy's Blog.
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 12-08-2005, 10:16 PM   #1
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
dlopen(), causing SIGBUS signal.... help


Hi all,
I m trying to open a corrupted .so file, through
dlopen() function. Some time it is returning error safely. And some time it is causing SIGBUS signal to be delivered. Because of this signal my program is crashing.
Corrupted .so file, means not complete shared library file i.e. half or 3/4 of a shared library file.

---------Help...
Can any body help me, why this is causing SIGBUS?

And how to avoid this program crash?

Is it safe to ignore SIGBUS signal?

Is there any such command or system call which can verify whether a given shared library is corrupted or not?
--------- Thanking U all

[ Note :: I m using C on Suse Linux platform ]

With Regard
RajSun
 
Old 12-08-2005, 11:00 PM   #2
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
This signal can not be caught or ignored, so you don't have a choice - it will terminate your application if you like it or not.

Now the library file, if its bad you again have no choice. Either get a good copy of the file or stop using it because it will never work.
 
Old 12-08-2005, 11:48 PM   #3
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Original Poster
Rep: Reputation: 15
Thanks for your reply...

Thanks for reply... man.

I want to know that whether is there any way to make sure the given shared library file is corrupted ?


With Regard
RajSun
 
Old 12-09-2005, 07:32 PM   #4
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
Yes, compare the questionable file with the good one.

$ cmp unknown.so goodone.so
unknown.so goodone.so differ: byte 1, line 1

so you know its bad because they differ.

Like I said you have to get a good copy of the file first.
Compile it from source if you have to.

Edit:
Try running nm on the file, it should print out some error
message if corrupt.

Last edited by randyding; 12-09-2005 at 07:38 PM.
 
Old 12-09-2005, 10:52 PM   #5
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Quote:
Originally Posted by randyding
This signal can not be caught or ignored, so you don't have a choice - it will terminate your application if you like it or not.
This is not true. Quoting signal(7):
"The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored."

What's the use of the pointers to the functions contained in the shared library? Remember that shared libraries are loaded dinamically. Post some code if you can.
 
Old 12-09-2005, 11:32 PM   #6
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
My experience with Bus faults is with embedded (not intel), when you get one of these you're so screwed there's often no good stack or program counter to continue execution. If intel allows you to catch one of these (it very well could) it won't help the OP because his problem is the library file's size was cut off through some copy error. His words "i.e. half or 3/4 of a shared library file". This is not recoverable whether the os actually lets you catch the signal or not. The process is doomed.
 
Old 12-10-2005, 12:09 AM   #7
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
It may be that with 3/4 the size you're hitting an incomplete instruction or a reference to data or functions that aren't present. By the way, if you're trying to make your program robust, then catching SIGBUS may help if you're trying to use a shared library as a plugin. You'd have to know where in the program you're dealing with functions in this library, like installing the handler before and so on
 
Old 12-11-2005, 10:07 PM   #8
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Original Poster
Rep: Reputation: 15
[HTML]Edit:
Try running nm on the file, it should print out some error
message if corrupt.[/HTML]


Thanks.... randyding

For me nm worked perfectly. This command is verifying the given .so file. If it is incomplete then it's return ing non zero value "256" and saying the symboles are missing.

Once again thanking u .....

With Regard
RajSun.
 
Old 12-11-2005, 10:08 PM   #9
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Edit:
Try running nm on the file, it should print out some error
message if corrupt.
Thanks.... randyding

For me nm worked perfectly. This command is verifying the given .so file. If it is incomplete then it's returning non zero value "256" and saying the symbols are missing.

Once again thanking u .....

With Regard
RajSun.

Last edited by rajsun; 12-11-2005 at 10:11 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Bus Error (core dumped) due to SIGBUS signal rajendra.badapanda Programming 10 07-19-2005 10:18 AM
Bus Error (core dumped) due to SIGBUS signal rajendra.badapanda Linux - Software 1 07-05-2005 12:10 PM
Forcing dlopen to look at LD_LIBRARY_PATH again wiredj Programming 2 09-24-2004 06:55 PM
Signal 6: Unknown Signal <=> Error with MAYA4.X under Linux SOLVED!!!! Faeroon Linux - Software 9 05-09-2003 01:57 PM
Signal: 6 (Unknown Signal) - Problems running a program Faeroon Linux - Software 86 01-14-2003 12:08 AM

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

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

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