• Advertisement

y18a

Member
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About y18a

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. Leak occurs when "shared class" exists.

    asCScriptFunction::~asCScriptFunction() { // Dummy functions that are allocated on the stack are not reference counted asASSERT( funcType == asFUNC_DUMMY || (externalRefCount.get() == 0 && internalRefCount.get() == 0) ); + printf(" + destruct %s\n", name.AddressOf());fflush(stdout); First of all, prepare as above. static const char *script1 = "shared class X { } \n" "X@ x = X();" ; static const char *script2 = "shared class X { }; \n" "void test() { \n" "} \n" ; bool Test() { bool fail = false; int r; CBufferedOutStream out; asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &out, asCALL_THISCALL); asIScriptModule *mod = engine->GetModule("Module1", asGM_ALWAYS_CREATE); mod->AddScriptSection("Script1", script1, strlen(script1), 0); mod->Build(); out.buffer = ""; mod = engine->GetModule("Module2", asGM_ALWAYS_CREATE); mod->AddScriptSection("Script2", script2, strlen(script2), 0); r = mod->Build(); if( r < 0 ) TEST_FAILED; if( out.buffer != "" ) TEST_FAILED; // discard `Module2` mod->Discard(); // game loop for(unsigned i = 0; i < 10; ++i) { engine->GarbageCollect(); // run DeleteDiscardedModules(); PRINTF("."); } PRINTF("gameloop done.\n"); engine->Release(); // Success return fail; } And then execute the above. ..........gameloop done. + destruct test The result will be as above. This indicates that `void test ()` was not deleted until the game loop terminated. + destruct test ..........gameloop done. Applying a patch to `asCModule :: HasExternalReferences` will result in the above.
  2. Leak occurs when "shared class" exists. `destructor` of asIScriptFunction will not be called, so I investigated it, I applied the following patch and improved it. bool asCModule::HasExternalReferences(bool shuttingDown) : : for( asUINT n = 0; n < classTypes.GetLength(); n++ ) if( classTypes[n] && classTypes[n]->externalRefCount.get() ) { + asCObjectType *type = classTypes[n]; + if( type->IsShared() ) + continue; .... Should I also check below? if( engine->FindNewOwnerForSharedType(type, this) != this )
  3. Although it is a report on experimental support, engine->SetEngineProperty(asEP_ALLOW_IMPLICIT_HANDLE_TYPES, 1); First, set asEP_ALLOW_IMPLICIT_HANDLE_TYPES to true. class@ A { A(A@ a) { } } class@ B : A { B(A@ a) { super(a); } } class@ C : B { C(A@ a) { super(a); } } int main() { auto a = A(null); auto c = C(a); auto b = B(c); return 0; } Then prepare the above code and execute asrun, an error will be output. $ ./asrun.exe script2.as script2.as (18, 1) : INFO : Compiling int main() script2.as (22, 8) : ERR : No default constructor for object of type 'B'. script2.as (22, 8) : ERR : No appropriate opAssign method found in 'B' for value assignment script2.as (0, 0) : ERR : Script failed to build If you change as follows, it works normally. auto b = B(@c); Alternatively, B@ b = B(c);
  4. void main() { for(;;) { } } After preparing the above code, executing asbuild stopped at assert. $ ./asbuild.exe config.txt script.as x.bin Assertion failed: *(asBYTE*)(bc+length-1) == asBC_RET, file ..\..\source\as_restore.cpp, line 4671 However, `while (true)` is fine. Also, I have not examined this properly, It seems to be related to this matter, so I will write on it later. void test() { : return; : : } Perhaps, I think so, If you have an `Unreachable code` like this, after you do SaveBytecode, you` assert` this binary on loading.
  5. Stopped at the following `ASSERT` and we investigated, void asCByteCode::AddPath(asCArray<asCByteInstruction *> &paths, asCByteInstruction *instr, int stackSize) { if( instr->marked ) { // Verify the size of the stack asASSERT(instr->stackSize == stackSize); Eventually, It was caused by the following. class A { }; class B { B() { print("B\n"); } }; int main() { A a; a.B(); return 0; } When preparing the above code and executing it, $ ./asrun.exe script2.as B It was due to normal compilation passing and normal operation. ps, I was surprised that someone wrote such code. Also, thank you very much for your support. I am grateful to you.
  6. interface A { }; interface B : A { }; After preparing the above code, executing asbuild stopped at assert. $ ./asbuild.exe config.txt script.as x.bin Assertion failed: t->interfaces.GetLength() == t->interfaceVFTOffsets.GetLength(), file ..\..\source\as_restore.cpp, line 4283 t->name.AddressOf() == "B" t->interfaces.GetLength() == 1 t->interfaceVFTOffsets.GetLength() == 0
  7. // `0x123` means the address of the object. weakref<X> active(0x123); free(0x123); // cache.push_back(0x123) And weakflag.Set(true) 0x123 = alloc(); // 0x123 = cache.pop_back() weakref<X> tmp(0x123); active = tmp; // Assignment is not executed because it is the following code // weakref.cpp: ::operator =(const CScriptWeakRef &other) // // Don't do anything if it is the same reference // if( m_ref == other.m_ref ) // return *this; if( active.get() is null ) { println("is null!!!!"); }
  • Advertisement