Thread View: comp.unix.programmer
6 messages
6 total messages
Started by Nabeel Shaheen
Wed, 09 Jul 2003 11:24
how to prevent prevent .so-calling routine to crash from segfaults in .so
Author: Nabeel Shaheen
Date: Wed, 09 Jul 2003 11:24
Date: Wed, 09 Jul 2003 11:24
28 lines
2103 bytes
2103 bytes
Hi, Guys I am stuck with a problem and need some help. Platform : Linux(RedHat 7.3) Problem Area : Dynamic Shared Object Libraries, POSIX Threads glibc : 2.96 Problem: ======= The Scenario is such that I have made a module which call a .so file in a new thread and executes it. The .so file has to be provided by the end-user and if that .so gives any runtime-error(SEGFAULTS), the whole process terminates i.e. all the threads executing .so files and more importantly my .so-calling module, which I dont want to be terminated. so ***IS THERE ANY WAY THAT MY SO-CALLING MODULE DOES NOT TERMINATE DUE TO SOME SEGFAULTS IN A .SO FILE WRITTEN BY THE END-USER OF MY MODULE?***. Any relevant comment will be appreciated. Best Regards, Nabeel Shaheen Sir Syed Research Labs nabsha[at]UNIssuet.edu.pk (remove capitals)
Re: how to prevent prevent .so-calling routine to crash from segfaults in .so
Author: mru
Date: Wed, 09 Jul 2003 11:51
Date: Wed, 09 Jul 2003 11:51
16 lines
1970 bytes
1970 bytes
sonicshaheen@yahoo.com (Nabeel Shaheen) writes: > so ***is there any way that my so-calling module does not terminate > due to some segfaults in a .so file written by the end-user of my > module?***. First, don't yell (fixed). The answer is no. If a module contains bad code that trashes your stack and/or head, there's nothing you can do to recover. Depending on your design, it could be possible to run all modules in separate processes, communicating through sockets, shared memory, or whatever. Then only the misbehaving process would be terminated. -- M�ns Rullg�rd mru@users.sf.net
Re: how to prevent prevent .so-calling routine to crash from segfaults in .so
Author: Rainer Temme
Date: Wed, 09 Jul 2003 11:54
Date: Wed, 09 Jul 2003 11:54
51 lines
3298 bytes
3298 bytes
"Nabeel Shaheen" <sonicshaheen@yahoo.com> wrote: > Hi, > > Guys I am stuck with a problem and need some help. > > Platform : Linux(RedHat 7.3) > Problem Area : Dynamic Shared Object Libraries, POSIX Threads > glibc : 2.96 > > Problem: > ======= > The Scenario is such that I have made a module which call a .so file > in a new thread and executes it. The .so file has to be provided by > the end-user and if that .so gives any runtime-error(SEGFAULTS), the > whole process terminates i.e. all the threads executing .so files and > more importantly my .so-calling module, which I dont want to be > terminated. > > so ***IS THERE ANY WAY THAT MY SO-CALLING MODULE DOES NOT TERMINATE > DUE TO SOME SEGFAULTS IN A .SO FILE WRITTEN BY THE END-USER OF MY > MODULE?***. > > Any relevant comment will be appreciated. Hi Nabeel, since the *.so file is provided by the end-user we cannot assume it to be ... ... free of errors (can we ever assume this?) ... protect itself against crashes etc. I think the only way to handle this problem is to use setjmp() /longjmp() along with a signal-handler registered for all relevant signals. Before each call to the user-so-file you register the actual settings with setjump(). Whenever a signal occurs the signal-routine will be called and can longjmp() to the previously stored position. At least, this way you'll be able to write a proper Log and to do a proper program-cleanup. Generally I wouldn't trust this construction to be stable enough so that the program can continue...the call to the user-so-file might have corrupted stack/heap and anything else (including the jumpbuf-structure stored with setjmp())...so that normal operation is not longer guaranteed. Regards ... Rainer
Re: how to prevent prevent .so-calling routine to crash from segfaults in .so
Author: Casper H.S. Dik
Date: Wed, 09 Jul 2003 12:07
Date: Wed, 09 Jul 2003 12:07
31 lines
2471 bytes
2471 bytes
sonicshaheen@yahoo.com (Nabeel Shaheen) writes: >The Scenario is such that I have made a module which call a .so file >in a new thread and executes it. The .so file has to be provided by >the end-user and if that .so gives any runtime-error(SEGFAULTS), the >whole process terminates i.e. all the threads executing .so files and >more importantly my .so-calling module, which I dont want to be >terminated. >so ***IS THERE ANY WAY THAT MY SO-CALLING MODULE DOES NOT TERMINATE >DUE TO SOME SEGFAULTS IN A .SO FILE WRITTEN BY THE END-USER OF MY >MODULE?***. No. Well, you can prevent it from terminating your program by catching SIGSEGV and doing a longjump or some such. But then you're left possibly with: - mutex locks held by the crashed thread - heap corruption caused by the crashed thread - other corruption/inconsitencies caused. I.e., the best you can do is die and restart. Casper -- Expressed in this posting are my opinions. They are in no way related to opinions held by my employer, Sun Microsystems. Statements on Sun products included here are not gospel and may be fiction rather than truth.
Re: how to prevent prevent .so-calling routine to crash from segfaults in .so
Author: Neil Horman
Date: Wed, 09 Jul 2003 12:41
Date: Wed, 09 Jul 2003 12:41
37 lines
2970 bytes
2970 bytes
Nabeel Shaheen wrote: > Hi, > > Guys I am stuck with a problem and need some help. > > Platform : Linux(RedHat 7.3) > Problem Area : Dynamic Shared Object Libraries, POSIX Threads > glibc : 2.96 > > Problem: > ======= > The Scenario is such that I have made a module which call a .so file > in a new thread and executes it. The .so file has to be provided by > the end-user and if that .so gives any runtime-error(SEGFAULTS), the > whole process terminates i.e. all the threads executing .so files and > more importantly my .so-calling module, which I dont want to be > terminated. > > so ***IS THERE ANY WAY THAT MY SO-CALLING MODULE DOES NOT TERMINATE > DUE TO SOME SEGFAULTS IN A .SO FILE WRITTEN BY THE END-USER OF MY > MODULE?***. > > Any relevant comment will be appreciated. > > Best Regards, > > Nabeel Shaheen > Sir Syed Research Labs > nabsha[at]UNIssuet.edu.pk (remove capitals) How about instead of creating a new thread, you re-architect your program to fork a child process to interact with the user supplied shared library? That way, if the .so file causes a segfault, the child will terminate, but the parent can detect the unclean exit, and inform the user, without needing to shut the whole program down. HTH Neil
Re: how to prevent prevent .so-calling routine to crash from segfaults in .so
Author: Nabeel Shaheen
Date: Wed, 09 Jul 2003 20:23
Date: Wed, 09 Jul 2003 20:23
54 lines
3148 bytes
3148 bytes
Neil Horman <nhorman@lvl7.com> wrote in message news:<4UTOa.1513$zJ6.1404@fe02.atl2.webusenet.com>... > Nabeel Shaheen wrote: > > Hi, > > > > Guys I am stuck with a problem and need some help. > > > > Platform : Linux(RedHat 7.3) > > Problem Area : Dynamic Shared Object Libraries, POSIX Threads > > glibc : 2.96 > > > > Problem: > > ======= > > The Scenario is such that I have made a module which call a .so file > > in a new thread and executes it. The .so file has to be provided by > > the end-user and if that .so gives any runtime-error(SEGFAULTS), the > > whole process terminates i.e. all the threads executing .so files and > > more importantly my .so-calling module, which I dont want to be > > terminated. > > > > so ***IS THERE ANY WAY THAT MY SO-CALLING MODULE DOES NOT TERMINATE > > DUE TO SOME SEGFAULTS IN A .SO FILE WRITTEN BY THE END-USER OF MY > > MODULE?***. > > > > Any relevant comment will be appreciated. > > > > Best Regards, > > > > Nabeel Shaheen > > Sir Syed Research Labs > > nabsha[at]UNIssuet.edu.pk (remove capitals) > > How about instead of creating a new thread, you re-architect your > program to fork a child process to interact with the user supplied > shared library? That way, if the .so file causes a segfault, the child > will terminate, but the parent can detect the unclean exit, and inform > the user, without needing to shut the whole program down. > HTH > Neil Hi Guys, Thanx a lot for ur valueable suggestion/information. I think Neil is right and therefore am restructuring the application as this seems to be the only legal way out of this hazardous environment. Thanx again for your comments Best Regards, Nabeel Shaheen Sir Syed Research Labs nabsha[at]UNIssuet.edu.pk (remove capitals)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads