Bug 4536 - race in FCatch's exec code
Summary: race in FCatch's exec code
Status: RESOLVED INVALID
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-22 18:05 UTC by Andrew Cagney
Modified: 2008-03-11 19:42 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cagney 2007-05-22 18:05:46 UTC
This code:

    
    if (attach == true)
      init();
    else
      {
        File exe = new File(command[0]);
        if (exe.exists())
          Manager.host.requestCreateAttachedProc(command, new CatchObserver());
        else
          {
            System.err.println("fcatch: can't find executable!");
            System.exit(1);
          }
      }

has a race - the executable could be removed between the exe.exists() call and
the requestCreateAttatchedProc call.

The code should instead handle the exec failure in the attatched observer.
Comment 1 Mike Cvet 2007-06-29 13:33:29 UTC
What should be done, beyond the following?

public void addFailed (Object observable, Throwable w)
{
  throw new RuntimeException("Failed to attach to created proc", w);
}
Comment 2 Andrew Cagney 2007-07-03 17:24:26 UTC
(In reply to comment #1)
> What should be done, beyond the following?
> 
> public void addFailed (Object observable, Throwable w)
> {
>   throw new RuntimeException("Failed to attach to created proc", w);
> }

Not much (And the test exe.exists() is removed) :-)

Just make certain that it is propogated back to main() so it can report the
error (in Throwable w) and exit.
Comment 3 Sami Wagiaalla 2008-03-11 19:42:39 UTC
This code segment has been rewritten.

commit 5492baa03cd955076e3b9cc5305def492de72920
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Mar 10 16:29:44 2008 -0400

    swagiaal: converted fcatch to use ProcRunUtil.
    
    frysk-core/frysk/bindir/ChangeLog
    +2008-03-10  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* fcatch.java: Moved the bulk of the code to FCatch.
    +
    
    frysk-core/frysk/debuginfo/ChangeLog
    +2008-03-10  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* DebugInfoStackFactory.java: Added DEFAULT options.
    +
    
    frysk-core/frysk/util/ChangeLog
    +2008-03-10  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* FCatch.java: Now uses ProcRunUtil.
    +	* TestFCatch.java: Deleted.
    +