🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3474

Re: how to prevent prevent .so-calling routine to crash from segfaults in .so

#3474
From: Neil Horman
Date: Wed, 09 Jul 2003 12:41
37 lines
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
Technical Details
Message-ID: <4UTOa.1513$zJ6.1404@fe02.atl2.webusenet.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!chi1.webusenet.com!c03.atl99!news.webusenet.com!pc01.webusenet.com!fe02.atl2.webusenet.com.POSTED!not-for-mail
References: <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: f65d0,e85a8f2945e25a1
X-Google-Attributes: gidf65d0,public
X-Google-Thread: 107b38,e85a8f2945e25a1
X-Google-Attributes: gid107b38,public
X-Google-Thread: fc89c,e85a8f2945e25a1
X-Google-Attributes: gidfc89c,public
X-Google-ArrivalTime: 2003-07-09 05:41:23 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!chi1.webusenet.com!c03.atl99!news.webusenet.com!pc01.webusenet.com!fe02.atl2.webusenet.com.POSTED!not-for-mail
From: Neil Horman <nhorman@lvl7.com>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030507
X-Accept-Language: en-us, en
MIME-Version: 1.0
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
References: <5a41f079.0307090324.3822c1bb@posting.google.com>
In-Reply-To: <5a41f079.0307090324.3822c1bb@posting.google.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 38
Message-ID: <4UTOa.1513$zJ6.1404@fe02.atl2.webusenet.com>
X-Complaints-To: abuse@usenetserver.com
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly.
NNTP-Posting-Date: Wed, 09 Jul 2003 08:28:48 EDT
Date: Wed, 09 Jul 2003 08:41:22 -0400