vshaxe / hxcpp-debugger

Visual Studio Code Debugger for Haxe/HXCPP applications
MIT License
26 stars 12 forks source link

Crash with lime.app Future #10

Closed sano98 closed 5 years ago

sano98 commented 6 years ago

Seems as if the debugger doesn't like the threading capabilities that come with the usage of the Future class in lime.app package. It throws the error:

Critical Error: Allocating from a GC-free thread.

and the debug server instantly crashes. This can be reproduced by inserting the following in any hello world (I used HaxeFlixel, but a lime program should suffice)

import lime.app.Future;

var future = new Future<Int>(testfunction, true);

function testfunction()
{
    trace("Hello");
}
nulld commented 6 years ago

which lime version?

sano98 commented 6 years ago

Lime: 7.0.0 and older (I tried it with the latest stable available builds, but it also occurs with older versions. Can't tell about unstable cutting edge dev versions)

Lime: 7.0.0 OpenFL: 8.4.1 Haxe Compiler: 3.4.7 hxcpp: 4.0.4 vscode: 1.27.2

nulld commented 6 years ago

Thank you, reproduced. This is callstack of exception. @hughsando, could you help me to figure out, what is going on here?:

    Mode.exe!`anonymous namespace'::DebuggerTrap() Line 78  C++
    Mode.exe!CriticalGCError(const char * inMessage) Line 523   C++
    Mode.exe!LocalAllocator::CallAlloc(int inSize, unsigned int inObjectFlags) Line 5772    C++
    Mode.exe!hx::InternalNew(int inSize, bool inIsObject) Line 6167 C++
    Mode.exe!hx::ArrayBase::ArrayBase(int inSize, int inReserve, int inElementSize, bool inAtomic) Line 26  C++
    Mode.exe!Array_obj<Dynamic>::Array_obj<Dynamic>(int inSize, int inReserve) Line 477 C++
    Mode.exe!Array_obj<Dynamic>::__new(int inSize, int inReserve) Line 1083 C++
    Mode.exe!hx::Object::__run(const Dynamic & a, const Dynamic & b) Line 183   C++
    Mode.exe!Dynamic::operator()(const Dynamic & inArg0, const Dynamic & inArg1) Line 306   C++
    Mode.exe!hx::DebuggerContext::attach(hx::StackContext * inStack) Line 147   C++
    Mode.exe!hx::dbgCtxAttach(hx::DebuggerContext * ctx, hx::StackContext * inStack) Line 355   C++
    Mode.exe!hx::StackContext::onThreadAttach() Line 232    C++
    Mode.exe!hx::RegisterCurrentThread(void * inTopOfStack) Line 6309   C++
>   Mode.exe!hx::SetTopOfStack(int * inTop, bool inForce) Line 6124 C++
    Mode.exe!hxThreadFunc(void * inInfo) Line 241   C++
    [External Code] 
    hxThreadInfo *info[2];
        info[0] = (hxThreadInfo *)inInfo;
        info[1] = 0;

    tlsCurrentThread = info[0];

238 hx::SetTopOfStack((int *)&info[1], true);

    // Release the creation function
241 info[0]->mSemaphore->Set();
nulld commented 6 years ago

After some time investigating callstack - created this issue: https://github.com/HaxeFoundation/hxcpp/issues/730

Gama11 commented 5 years ago

@nulld's fix (https://github.com/HaxeFoundation/hxcpp/pull/735) has been merged into hxcpp, so I think this can be closed now.