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

Ask a Question related to UNIX Programming, Design and Development.

  1. #1

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

    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)
    Nabeel Shaheen Guest

  2. Similar Questions and Discussions

    1. Prevent Hotlinking
      I am new to Adobe products, so not exactly sure if the Adobe Media Server suits our needs. We are working towards an app that provides streaming mp3...
    2. Prevent Printing?
      Is it possible to prevent an entire page, or a few elements of a page, from being printed? Geoff
    3. how to prevent add new row to datagrid
      I have a datagrid bound to a table in an access database, and would like to have users only add new records through a input form so that I can...
    4. Prevent Cashing swf
      Hi all Anybody knows how to prevent my SWF file to not be cashed by PHP. Any help or idea greatly will be appreciated. Thanks in advanced Behzad...
    5. How to prevent changes to CheckBoxList
      Hello. Can anyone tell me if there is ANY way to prevent the user changing the values in a checkboxlist. I just want to use it for information...
  3. #2

    Default Re: how to prevent prevent .so-calling routine to crash fromsegfaults in .so

    [email]sonicshaheen@yahoo.com[/email] (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
    [email]mru@users.sf.net[/email]
    mru@users.sourceforge.net Guest

  4. #3

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

    [email]sonicshaheen@yahoo.com[/email] (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.
    Casper H.S. Dik Guest

  5. #4

    Default Re: how to prevent prevent .so-calling routine to crash from segfaultsin .so

    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


    Neil Horman Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139