HaxeFoundation / hxcpp-debugger

Cross-platform debugger for hxcpp
Apache License 2.0
49 stars 16 forks source link

Crash on start: Bad local allocator - requesting memory from unregistered thread! #16

Closed nulld closed 7 years ago

nulld commented 7 years ago

I'm trying to launch app with debugger on windows10 platform in local mode: new debugger.Local(true);

Debugger starts normaly: image

But after send c command, it throws Bad local allocator - requesting memory from unregistered thread!

This is Call Stack from visual studio: image

EricBishton commented 7 years ago

What versions of compiler, hxcpp, and hxcpp-debugger are you using? Are they versions you built yourself?

nulld commented 7 years ago

haxe 3.4.0

hxcpp-debugger from git: F:\devel\haxelib\hxcpp-debugger (master) commit 4f8571c523870fe63a92aef9800d6433ca6bc02e

hxcpp from git F:\devel\haxelib\hxcpp (master) λ git log commit 67aebc2c417d1e3f1133d7616887c5fded75e977

bjitivo commented 7 years ago

I suspect this is due to changes in the GC implementation in haxe; the developers of the hxcpp-debugger haxelib (TiVo) use a custom garbage collector that doesn't have whatever requirement the Immix garbage collector that comes with stock hxcpp requires. Therefore we don't see this problem.

Looking at the code involved and the stack trace, it looks like a bug in Immix.cpp; its SetTopOfStack function is supposed to "register" a local allocator to be used by the calling thread, but in the process of registering that thread, it's trying to allocate something, and since the local allocator has not been registered yet, that allocation is failing.

The root cause of this appears to be the addition of the onThreadAttach() call at the end of the LocalAllocator constructor within Immix.cpp. This was added in commit 269e2292dc4a5e6556520ce52616dd8c1b0b3881 by hughsando on Sep 25, 2016. The addition of this call at that point in the code makes the debugger crash.

I recommend that you submit an issue to the hxcpp project:

https://github.com/HaxeFoundation/hxcpp

Letting them know that they broke the hxcpp built-in debugger with that change.

hughsando commented 7 years ago

Looks like I need to delay the attaching until after the constructor.

EricBishton commented 7 years ago

This will be fixed when https://github.com/HaxeFoundation/hxcpp/issues/565 is fixed.

hughsando commented 7 years ago

I have put in a fix, https://github.com/HaxeFoundation/hxcpp/commit/65a23408f3bdeaa3af7452bdc48eb417c0974ecd which I think should do the job.

nulld commented 7 years ago

Thanks, it works now