Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


- - - - -

Pod type and Null pointer exception - bug with call destructor


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 FDsagizi   Members   -  Reputation: 514

Like
1Likes
Like

Posted 25 September 2012 - 04:08 AM

Hello!

I find bug Posted Image

if comment this code

// null_object.Do();

destructor call 2 times - it is ok!

but, if we have null pointer exception

destructor call 3 times and c++ crash

http://www.everfall....hp?nt1d6pbl1rkg

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3417

Like
0Likes
Like

Posted 03 October 2012 - 07:19 PM

Thanks. I'll look into this.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Andreas Jonsson   Moderators   -  Reputation: 3417

Like
0Likes
Like

Posted 07 October 2012 - 06:59 PM

I haven't been able to reproduce this problem. I wrote the following test:

{
  COutStream out;
  asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
  engine->SetMessageCallback(asMETHOD(COutStream, Callback), &out, asCALL_THISCALL);
  engine->RegisterObjectType("TestLink", sizeof(CObject), asOBJ_VALUE | asOBJ_APP_CLASS_CD);
  engine->RegisterObjectBehaviour("TestLink", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(Construct), asCALL_CDECL_OBJLAST);
  engine->RegisterObjectBehaviour("TestLink", asBEHAVE_CONSTRUCT, "void f(const TestLink &in)", asFUNCTION(CopyConstruct), asCALL_CDECL_OBJLAST);
  engine->RegisterObjectBehaviour("TestLink", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(Destruct), asCALL_CDECL_OBJLAST);
  asIScriptModule *mod = engine->GetModule("mod", asGM_ALWAYS_CREATE);
  mod->AddScriptSection("test",
   "class Object3 \n"
   "{ \n"
   "    Object3( TestLink str ) \n"
   "    { \n"
   "	    Object3 @null_object = null; \n"
   "	    null_object.Do(); \n"
   "    } \n"
   "    void Do() {} \n"
   "} \n"
   "void Main() \n"
   "{ \n"
   "   Object3 @oo = Object3( TestLink() ); \n"
   "} \n");
  r = mod->Build();
  if( r < 0 )
   TEST_FAILED;
  CObject_constructCount = 0;
  CObject_destructCount = 0;
  asIScriptContext *ctx = engine->CreateContext();
  r = ExecuteString(engine, "Main()", mod, ctx);
  if( r != asEXECUTION_EXCEPTION )
   TEST_FAILED;
  if( CObject_constructCount != 2 ||
   CObject_destructCount != 1 )
   TEST_FAILED;
  ctx->Release();
  if( CObject_constructCount != 2 ||
   CObject_destructCount != 2 )
   TEST_FAILED;
  engine->Release();
}

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#4 Jake Albano   Members   -  Reputation: 647

Like
0Likes
Like

Posted 08 October 2012 - 09:15 PM

FDsagizi, when you say "Pod type", do you mean that the type is registered with asOBJ_CLASS_POD? POD types aren't allowed to have user-defined destructors.

http://en.wikipedia.org/wiki/Plain_old_data_structure

Not sure if that's relevant, but it might be confusing the compiler.

#5 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 09 October 2012 - 08:20 AM

Hmm... It was not easy to play with a simple example, I'm trying to find a more exact cause.

#6 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 09 October 2012 - 08:54 AM

This bug show after Save And Load byte code!

Code: http://www.everfall.com/paste/id.php?ic54qs57asxq

#7 Andreas Jonsson   Moderators   -  Reputation: 3417

Like
0Likes
Like

Posted 10 October 2012 - 07:03 PM

Ah, that puts a different light on the subject. I'll investigate with the new info.

Thanks,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#8 Andreas Jonsson   Moderators   -  Reputation: 3417

Like
0Likes
Like

Posted 11 October 2012 - 06:48 PM

Thanks a lot. I've fixed the problem in revision 1430.

It was a flag 'dontCleanupOnException' that I had forgotten to serialize with the saved bytecode.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS