ソースを参照

Found the real cause of segfaults, it was the order in which delayed hooks was been called, it should call in last in first out order, before it was first in first out.

mingodad 13 年 前
コミット
d95b4136d8
2 ファイル変更4 行追加10 行削除
  1. 3 9
      ext/sq_axtls.c
  2. 1 1
      squirrel/sqstate.cpp

+ 3 - 9
ext/sq_axtls.c

@@ -27,13 +27,8 @@ static const SQChar SSL_Tag[]   = _SC("sq_axtls_ssl");
 
 
 static SQInteger ssl_release_hook(SQUserPointer p, SQInteger size, HSQUIRRELVM v)
 static SQInteger ssl_release_hook(SQUserPointer p, SQInteger size, HSQUIRRELVM v)
 {
 {
-    /*
-    axtls mantains a list of ssl connections on ssl_ctx
-    on case of program abort it frees there all ssl connections
-    and if we try to do it here we get segault
-    */
-    //SSL *self = (SSL*)p;
-    //if(self) ssl_free(self);
+    SSL *self = (SSL*)p;
+    if(self) ssl_free(self);
 	return 0;
 	return 0;
 }
 }
 
 
@@ -42,7 +37,6 @@ static SQInteger sq_ssl_free(HSQUIRRELVM v)
     SQ_FUNC_VARS_NO_TOP(v);
     SQ_FUNC_VARS_NO_TOP(v);
     GET_ssl_INSTANCE();
     GET_ssl_INSTANCE();
     ssl_release_hook(self, 0, v);
     ssl_release_hook(self, 0, v);
-    ssl_free(self);
     sq_setinstanceup(v, 1, 0);
     sq_setinstanceup(v, 1, 0);
 	return 0;
 	return 0;
 }
 }
@@ -243,7 +237,7 @@ static int sq_axtls_get_error(HSQUIRRELVM v){
 }
 }
 
 
 static SQInteger ssl_ctx_release_hook(SQUserPointer p, SQInteger size, HSQUIRRELVM v)
 static SQInteger ssl_ctx_release_hook(SQUserPointer p, SQInteger size, HSQUIRRELVM v)
-{
+{
     SSL_CTX *self = (SSL_CTX*)p;
     SSL_CTX *self = (SSL_CTX*)p;
     if(self) ssl_ctx_free(self);
     if(self) ssl_ctx_free(self);
 	return 0;
 	return 0;

+ 1 - 1
squirrel/sqstate.cpp

@@ -247,7 +247,7 @@ void SQSharedState::CallDelayedReleaseHooks(SQVM *vm, int count)
         //calling each release hook new ones can be added
         //calling each release hook new ones can be added
         //to the list, the new ones will be processed on next call
         //to the list, the new ones will be processed on next call
         if(count == 0) count =  _delayed_release_hook.size();
         if(count == 0) count =  _delayed_release_hook.size();
-        for(SQInteger i=0; i < count; ++i){
+        for(SQInteger i=count-1; i >= 0; --i){
             SQDelayedReleseHook &dh = _delayed_release_hook[i];
             SQDelayedReleseHook &dh = _delayed_release_hook[i];
             dh.hook(dh.ptr, dh.size, vm);
             dh.hook(dh.ptr, dh.size, vm);
         }
         }