When an application crashes...

Discussion in 'C++' started by Alexander Dong Back Kim, Apr 11, 2008.

  1. Hi all,

    I'm working on a Linux machine and using g++. I'm developing an
    semaphore module for a number of applications in the system.

    My question scenario is, an application can lock a resource which is
    shared memory segment in this case, after they locked a segment and if
    they somehow crash then the lock won't be released because the
    application locked the resource is dead.

    I hope there must be a way to release the lock so solve this problem
    even the application is crashed unexpectedly.

    Any idea?

    best regards,

    Alex D. B. Kim
    Alexander Dong Back Kim, Apr 11, 2008
    #1
    1. Advertising

  2. Alexander Dong Back Kim

    red floyd Guest

    Alexander Dong Back Kim wrote:
    > Hi all,
    >
    > I'm working on a Linux machine and using g++. I'm developing an
    > semaphore module for a number of applications in the system.
    >
    > My question scenario is, an application can lock a resource which is
    > shared memory segment in this case, after they locked a segment and if
    > they somehow crash then the lock won't be released because the
    > application locked the resource is dead.
    >
    > I hope there must be a way to release the lock so solve this problem
    > even the application is crashed unexpectedly.
    >


    What is your C++ question? You're OT here. Ask in a Linux newsgroup.

    1. If your question makes sense if you change the language, then it's
    OT in comp.lang.c++.
    2. If you question would not make sense if you change your platform
    (i.e. linux=>windows), then it's OT in comp.lang.c++.
    red floyd, Apr 11, 2008
    #2
    1. Advertising

  3. Alexander Dong Back Kim

    Guest

    On Apr 11, 10:42 am, Alexander Dong Back Kim <>
    wrote:

    >
    > I hope there must be a way to release the lock so solve this problem
    > even the application is crashed unexpectedly.


    I think it would be better to find out why it's crashing and fix
    that. If you post some code, maybe we can help.
    , Apr 11, 2008
    #3
  4. Alexander Dong Back Kim

    peter koch Guest

    On 11 Apr., 17:42, Alexander Dong Back Kim <>
    wrote:
    > Hi all,
    >
    > I'm working on a Linux machine and using g++. I'm developing an
    > semaphore module for a number of applications in the system.
    >
    > My question scenario is, an application can lock a resource which is
    > shared memory segment in this case, after they locked a segment and if
    > they somehow crash then the lock won't be released because the
    > application locked the resource is dead.
    >
    > I hope there must be a way to release the lock so solve this problem
    > even the application is crashed unexpectedly.
    >
    > Any idea?
    >
    > best regards,
    >
    > Alex D. B. Kim


    This should be possible with some kind of heavyweight structure, but
    the interesting question is why you would ever want to do that! If the
    application crashes while it holds the semaphore, this datastructure
    should by definition be defined as corrupted.
    As to how to do it, I suggest a Linux group.

    /Peter
    peter koch, Apr 11, 2008
    #4
  5. Alexander Dong Back Kim

    red floyd Guest

    peter koch wrote:
    > On 11 Apr., 17:42, Alexander Dong Back Kim <>
    > wrote:
    >> Hi all,
    >>
    >> I'm working on a Linux machine and using g++. I'm developing an
    >> semaphore module for a number of applications in the system.
    >>
    >> My question scenario is, an application can lock a resource which is
    >> shared memory segment in this case, after they locked a segment and if
    >> they somehow crash then the lock won't be released because the
    >> application locked the resource is dead.
    >>
    >> I hope there must be a way to release the lock so solve this problem
    >> even the application is crashed unexpectedly.
    >>
    >> Any idea?
    >>
    >> best regards,
    >>
    >> Alex D. B. Kim

    >
    > This should be possible with some kind of heavyweight structure, but
    > the interesting question is why you would ever want to do that! If the
    > application crashes while it holds the semaphore, this datastructure
    > should by definition be defined as corrupted.
    > As to how to do it, I suggest a Linux group.
    >


    He may be using SystemV IPC, which functions that way by design.
    red floyd, Apr 11, 2008
    #5
  6. On Apr 12, 2:15 am, red floyd <> wrote:
    > Alexander Dong Back Kim wrote:
    >
    > > Hi all,

    >
    > > I'm working on a Linux machine and using g++. I'm developing an
    > > semaphore module for a number of applications in the system.

    >
    > > My question scenario is, an application can lock a resource which is
    > > shared memory segment in this case, after they locked a segment and if
    > > they somehow crash then the lock won't be released because the
    > > application locked the resource is dead.

    >
    > > I hope there must be a way to release the lock so solve this problem
    > > even the application is crashed unexpectedly.

    >
    > What is your C++ question? You're OT here. Ask in a Linux newsgroup.
    >
    > 1. If your question makes sense if you change the language, then it's
    > OT in comp.lang.c++.
    > 2. If you question would not make sense if you change your platform
    > (i.e. linux=>windows), then it's OT in comp.lang.c++.


    so what? are you the manager of this group or what? If you don't know
    the answer then just shut up.
    Alexander Dong Back Kim, Apr 11, 2008
    #6
  7. On Apr 12, 2:15 am, red floyd <> wrote:
    > Alexander Dong Back Kim wrote:
    >
    > > Hi all,

    >
    > > I'm working on a Linux machine and using g++. I'm developing an
    > > semaphore module for a number of applications in the system.

    >
    > > My question scenario is, an application can lock a resource which is
    > > shared memory segment in this case, after they locked a segment and if
    > > they somehow crash then the lock won't be released because the
    > > application locked the resource is dead.

    >
    > > I hope there must be a way to release the lock so solve this problem
    > > even the application is crashed unexpectedly.

    >
    > What is your C++ question? You're OT here. Ask in a Linux newsgroup.
    >
    > 1. If your question makes sense if you change the language, then it's
    > OT in comp.lang.c++.
    > 2. If you question would not make sense if you change your platform
    > (i.e. linux=>windows), then it's OT in comp.lang.c++.


    so what? are you the manager of this group or what? If you don't know
    the answer then just shut up.
    Alexander Dong Back Kim, Apr 11, 2008
    #7
  8. On Apr 12, 3:31 am, peter koch <> wrote:
    > On 11 Apr., 17:42, Alexander Dong Back Kim <>
    > wrote:
    >
    >
    >
    > > Hi all,

    >
    > > I'm working on a Linux machine and using g++. I'm developing an
    > > semaphore module for a number of applications in the system.

    >
    > > My question scenario is, an application can lock a resource which is
    > > shared memory segment in this case, after they locked a segment and if
    > > they somehow crash then the lock won't be released because the
    > > application locked the resource is dead.

    >
    > > I hope there must be a way to release the lock so solve this problem
    > > even the application is crashed unexpectedly.

    >
    > > Any idea?

    >
    > > best regards,

    >
    > > Alex D. B. Kim

    >
    > This should be possible with some kind of heavyweight structure, but
    > the interesting question is why you would ever want to do that! If the
    > application crashes while it holds the semaphore, this datastructure
    > should by definition be defined as corrupted.
    > As to how to do it, I suggest a Linux group.
    >
    > /Peter



    Hi Peter,

    The reason why I'm looking for this solution is, currently, I'm
    developing an real time system using IPC. In the system, many
    processes will run at the same time and they are independent from each
    other. They also need to share their data so they are using shared
    memory as a medium. However, since they can access and update the
    shared memory simultaneously, I have been asked to implement a
    implementation of a read/write lock for the multiple applications.
    Therefore, I chose semaphore for this.

    The problem of semaphore is, although they works beautifully, if a
    process lock the semaphore and crashes immediately after the lock,
    then the lock won't be unlocked. Therefore, there is no way other
    applications can access the locked resource. Because of this reason, I
    think I have to somehow protect unexpected terminations. In other
    words, in order to unlock the resource before the process dies, I
    think I have to catch some system message or destructor of the class.
    I tried destructor way but it didn't call the destructor when the
    application is unexpectedly killed.

    Any suggestion for solving this problem?

    Cheers,
    Alexander Dong Back Kim, Apr 12, 2008
    #8
  9. Alexander Dong Back Kim

    Ian Collins Guest

    Alexander Dong Back Kim wrote:
    > On Apr 12, 2:15 am, red floyd <> wrote:


    >> Ask in a Linux newsgroup.

    >
    > so what? are you the manager of this group or what? If you don't know
    > the answer then just shut up.
    >

    You where given the correct answer, see above. Your question was a
    Linux/Unix one rather than a C++ language one.

    --
    Ian Collins.
    Ian Collins, Apr 12, 2008
    #9
  10. Alexander Dong Back Kim

    Ian Collins Guest

    Alexander Dong Back Kim wrote:
    >
    > The problem of semaphore is, although they works beautifully, if a
    > process lock the semaphore and crashes immediately after the lock,
    > then the lock won't be unlocked. Therefore, there is no way other
    > applications can access the locked resource. Because of this reason, I
    > think I have to somehow protect unexpected terminations. In other
    > words, in order to unlock the resource before the process dies, I
    > think I have to catch some system message or destructor of the class.
    > I tried destructor way but it didn't call the destructor when the
    > application is unexpectedly killed.
    >
    > Any suggestion for solving this problem?
    >

    Yes, ask the experts on either a linux group or comp.unix.programmer.
    There are a number of issues tied up on your question, some are system
    specific (Sys V IPC) other more generic programming (how do you manage
    possibly corrupt shared data if process crashes with a lock held).

    Have fun.

    --
    Ian Collins.
    Ian Collins, Apr 12, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Rebbeck

    ASP.NET application times out or crashes

    John Rebbeck, Nov 6, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    344
    John Rebbeck
    Nov 6, 2003
  2. klops
    Replies:
    0
    Views:
    356
    klops
    May 14, 2004
  3. Ronald
    Replies:
    3
    Views:
    3,593
    Jerom
    Oct 23, 2006
  4. Replies:
    4
    Views:
    578
    Default User
    Jan 17, 2007
  5. =?Utf-8?B?UmVmYWVsIEFja2VybWFubg==?=

    Crashes on an ASP.NET application

    =?Utf-8?B?UmVmYWVsIEFja2VybWFubg==?=, Jun 25, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    535
    bruce barker
    Jun 25, 2007
Loading...

Share This Page