Article View: comp.unix.programmer
Article #3471Re: how to prevent prevent .so-calling routine to crash from segfaults in .so
From: 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
Technical Details
Message-ID:
<begvk2$clt$1@news.mch.sbs.de>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!news-FFM2.ecrc.net!newsfeed.siemens.de!news.mch.sbs.de!not-for-mailReferences:
<5a41f079.0307090324.3822c1bb@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,e85a8f2945e25a1 X-Google-Attributes: gid11318c,public X-Google-Thread: 10c696,e85a8f2945e25a1 X-Google-Attributes: gid10c696,public X-Google-Thread: fc89c,e85a8f2945e25a1 X-Google-Attributes: gidfc89c,public X-Google-Thread: 107b38,e85a8f2945e25a1 X-Google-Attributes: gid107b38,public X-Google-Thread: f65d0,e85a8f2945e25a1 X-Google-Attributes: gidf65d0,public X-Google-ArrivalTime: 2003-07-09 04:51:31 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!news-FFM2.ecrc.net!newsfeed.siemens.de!news.mch.sbs.de!not-for-mail From: "Rainer Temme" <Rainer.Temme@NoSpam.Siemens.Com> Newsgroups: comp.unix.programmer,gnu.gcc.help,gnu.gcc,comp.os.linux.redhat,comp.os.linux.development.apps Subject: Re: how to prevent prevent .so-calling routine to crash from segfaults in .so Date: Wed, 9 Jul 2003 13:54:18 +0200 Organization: Siemens Business Services Lines: 54 Message-ID: <begvk2$clt$1@news.mch.sbs.de> References: <5a41f079.0307090324.3822c1bb@posting.google.com> NNTP-Posting-Host: was3604.kstm.sbs.de X-Trace: news.mch.sbs.de 1057751490 12989 141.73.105.172 (9 Jul 2003 11:51:30 GMT) X-Complaints-To: abuse@siemens.de NNTP-Posting-Date: Wed, 9 Jul 2003 11:51:30 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4922.1500 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800