Przeglądaj źródła

HPCC-23232 Eclagent's use of QueryTerminationCleanup wrong.

QueryTerminationCleanup at the end process, must clearup
before the query dll is unloaded.
If it waits until atexit, any hooks installed by the query
dll of dependent dlls, will be called to late and could crash.

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith 5 lat temu
rodzic
commit
e94a3a4c2d
3 zmienionych plików z 5 dodań i 3 usunięć
  1. 1 1
      ecl/eclagent/eclagent.cpp
  2. 1 1
      roxie/ccd/ccdcontext.cpp
  3. 3 1
      system/jlib/jthread.hpp

+ 1 - 1
ecl/eclagent/eclagent.cpp

@@ -1877,7 +1877,7 @@ void EclAgent::doProcess()
         {
             MTIME_SECTION(queryActiveTimer(), "Process");
             Owned<IEclProcess> process = loadProcess();
-            QueryTerminationCleanup threadCleanup;
+            QueryTerminationCleanup threadCleanup(false);
 
             if (checkVersion && (process->getActivityVersion() != eclccCodeVersion))
                 failv(0, "Inconsistent interface versions.  Workunit was created using eclcc for version %u, but the c++ compiler used version %u", eclccCodeVersion, process->getActivityVersion());

+ 1 - 1
roxie/ccd/ccdcontext.cpp

@@ -2959,7 +2959,7 @@ public:
     virtual void process()
     {
         MTIME_SECTION(myTimer, "Process");
-        QueryTerminationCleanup threadCleanup;
+        QueryTerminationCleanup threadCleanup(true);
         EclProcessFactory pf = (EclProcessFactory) factory->queryDll()->getEntry("createProcess");
         Owned<IEclProcess> p = pf();
         try

+ 3 - 1
system/jlib/jthread.hpp

@@ -67,8 +67,10 @@ extern jlib_decl void callThreadTerminationHooks(bool isPooled);
 //An exception safe way of ensuring that the thread termination hooks are called.
 class jlib_decl QueryTerminationCleanup
 {
+    bool isPooled;
 public:
-    inline ~QueryTerminationCleanup() { callThreadTerminationHooks(true); }
+    inline QueryTerminationCleanup(bool _isPooled) : isPooled(_isPooled) { }
+    inline ~QueryTerminationCleanup() { callThreadTerminationHooks(isPooled); }
 };
 
 class jlib_decl Thread : public CInterface, public IThread