Jump to content

  • Log In with Google      Sign In   
  • Create Account

_Engine_

Member Since 24 Nov 2003
Offline Last Active Apr 29 2016 02:12 AM

Topics I've Started

Crash on iOS arm64

08 April 2016 - 07:43 AM

Hi!

 

Looks like i found bug in angle script that leads to crashes on iOS arm64. I will try to explain details.

 

Problematic script is very simple:

void main()
{
    NGUIWidget@ wgt = @scene::inst;
    wgt.alpha = 0.58f;
}

 

Variable scene::inst are type of NGUISymbol0Instance and it is binded class from C++. NGUIWidget are also binded class from c++.

 

For NGUISymbol0Instance we register implicitly cast function to NGUIWidget.

 

Binding of cast function looks like

Machine()->RegisterObjectMethod("NGUISymbol0Instance", "NGUIWidget@ opImplCast()", asFUNCTION(NGUIWidgetCastGeneric));

Cast function looks like:

void NGUIWidgetCastGeneric(asIScriptGeneric *gen)
{
//On iOS arm64 pointer to object are corrupted and this leads to crash
void* obj = gen->GetObject();
}

Bytecode of function main are follow:

asBC_SUSPEND
asBC_PshGPtr
asBC_RefCpyV
asBC_PopPtr
asBC_ClrVPtr
asBC_CmpPtr
asBC_JZ
asBC_PshVPtr
asBC_CALLSYS

On asBC_RefCpyV correct pointer to C++ class copied to (void**)asPWORD(l_fp - asBC_SWORDARG0(l_bc));

On pc pointer address copied to 0x070d6900

On iOS 64 pointer address copied to 0x12802a1f0

 

On asBC_ClrVPtr on to (void**)asPWORD(l_fp - asBC_SWORDARG0(l_bc)); copied 0.

On pc address  is 0x070d68fc and all goes fine because on pc size of pointer is 4.

On iOS 64 address is 0x12802a1ec and this is a moment when all things goes bad. On arm64 size of pointer is 8. So coping 0 to 0x12802a1ec leads to corruption of 0x12802a1f0

 

On asBC_CALLSYS function NGUIWidgetCastGeneric are called. When we extract object address from asIScriptGeneric we get corrupted pointer.

 

I hope my explanation enough to investigate problem.

 


How use delegates from c++

24 November 2015 - 11:48 AM

Hi!
 
I try to implement passing delegates as arguments from script and call it from c++.
 
i use follow code to store script function - 
 

void ScriptModuleCore::Network::SetDelegate(DelegateAS& delegateAS, asIScriptFunction* cb)
{
   asIScriptEngine* engine = ((ScriptMachine*)(core->Script()->Machine()))->Machine();
 
   if (delegateAS.callback)
   {
     delegateAS.callback->Release();
   }
 
   if (delegateAS.callbackObject)
   {
      engine->ReleaseScriptObject(delegateAS.callbackObject, delegateAS.callbackObjectType);
   }
 
   delegateAS.callback = 0;
   delegateAS.callbackObject = 0;
   delegateAS.callbackObjectType = 0;
 
   if( cb && cb->GetFuncType() == asFUNC_DELEGATE )
   {
      delegateAS.callbackObject     = cb->GetDelegateObject();
      delegateAS.callbackObjectType = cb->GetDelegateObjectType();
      delegateAS.callback           = cb->GetDelegateFunction();
 
      engine->AddRefScriptObject(delegateAS.callbackObject, delegateAS.callbackObjectType);
 
      delegateAS.callback->AddRef();

      cb->Release();
   }
   else
   {
      delegateAS.callback = cb;
   }
} 

follow code executes script function

asIScriptContext* ctx = GrabContext();
	
ctx->Prepare(script_func);			

ctx->SetObject(hack_callbackObject);

ctx->Execute();

All fine when we deal with just function. But if we pass delegate than we got assertion in AngelScript in follow function -

// internal
int asCScriptFunction::GetRefCount()
{
   asASSERT( funcType == asFUNC_DELEGATE );
 
   return externalRefCount.get();
}

Maybe i just doing something wrong when dealing with delegate from c++ or this is bug in AngelScript?


Very slow loading of bytecode on iOS

18 June 2015 - 09:41 AM

Hi!

 

Currently we optimizing loading time of our application. Now 11 seconds needed to start application. After profiling we found that approximately 3 seconds needed to load byte code. According profile almost all time was spended in asCReader::Reader(bool*). More details are visible on screenshot - http://rghost.ru/7sxkVzWv8

 

It is possible to speed up loading of byte code? Loading speed are very critical to us and without your help we can't achieve satisfying result.


bug in scriptarray add-on

09 January 2015 - 04:55 AM

Hi!

 

in scriptarray.cpp there are nasty bug in ScriptArrayIsEmpty_Generic function - result of self->IsEmpty is not returned to asIScriptGeneric, because missing call such as *reinterpret_cast<bool *>(gen->GetAddressOfReturnLocation()) = self->IsEmpty();


Binding cast functions

25 August 2014 - 03:28 AM

Hi!

 

We are binding C++ classes and cast functions from base class. We get errors like this - "0:50.375 -  (0, 0) : ERR : Type 'SymbolInstSplashScreenSymbol' is still used by function 'SymbolInstSplashScreenSymbol@ NGUIWidget::_beh_10_()'" when in script we use cast functions. When we close scene angelscript are crushes (screenshot of call stack are attached). We use flags asBEHAVE_REF_CAST and asBEHAVE_IMPLICIT_REF_CAST when register cast functions.

 

If we are use flags asBEHAVE_VALUE_CAST and asBEHAVE_IMPLICIT_ witch looks like more properly because we do not need any reference count when use cast operator than all things became more badly - more errors comes and our scene crushes after binding not after closing as was before.

 

So looks like using cast functions leads to unnecessary reference count and this leads to internal crush of angelscript.


PARTNERS