[DynInst_API:] [PATCH 2/3] dyninstAPI: Check for termination after removing tracedSyscalls


Date: Thu, 6 Feb 2014 18:33:28 -0800
From: Josh Stone <jistone@xxxxxxxxxx>
Subject: [DynInst_API:] [PATCH 2/3] dyninstAPI: Check for termination after removing tracedSyscalls
It's possible to get markExited() while handling events for the
tracedSyscalls_->remove* calls, which makes the following pcProc_->detach()
a NULL dereference.  Simply calling isTerminated() protects this case.
---
 dyninstAPI/src/dynProcess.C | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/dyninstAPI/src/dynProcess.C b/dyninstAPI/src/dynProcess.C
index de9945e73dcc..0e52f0e05805 100644
--- a/dyninstAPI/src/dynProcess.C
+++ b/dyninstAPI/src/dynProcess.C
@@ -1174,8 +1174,10 @@ bool PCProcess::detachProcess(bool /*cont*/) {
 
     // TODO figure out if ProcControl should care about continuing a process
     // after detach
-    
-    if( pcProc_->detach() ) {
+
+    // NB: it's possible to get markExited() while handling events for the
+    // tracedSyscalls_->remove* calls above, clearing pcProc_.
+    if( isTerminated() || pcProc_->detach() ) {
         attached_ = false;
         return true;
     }
@@ -2086,7 +2088,6 @@ bool PCProcess::postIRPC_internal(void *buf,
                                   bool userRPC,
                                   bool isMemAlloc,
                                   void **result) {
-   assert(pcProc_);
    if( isTerminated() ) {
       proccontrol_printf("%s[%d]: cannot post RPC to exited or terminated process %d\n",
                          FILE__, __LINE__, getpid());
-- 
1.8.5.3

[← Prev in Thread] Current Thread [Next in Thread→]