deltaluca / nape

Haxe/AS3 Physics Engine
http://napephys.com
Other
542 stars 77 forks source link

Initializing static var with CbType instance crashes on Neko #101

Open Gama11 opened 8 years ago

Gama11 commented 8 years ago
package;

import nape.callbacks.CbType;

class Main
{
    public static var cb = new CbType();
    public static function main() {}
}
haxe -main Main -lib nape -neko run.n
neko run.n
Called from zpp_nape/callbacks/CbType.hx line 348
Called from nape/callbacks/CbType.hx line 179
Called from nape/callbacks/CbType.hx line 198
Called from zpp_nape/callbacks/CbType.hx line 174
Called from zpp_nape/callbacks/CbType.hx line 353
Called from zpp_nape/ID.hx line 186
Uncaught exception - Invalid operation (+)

Haxe 3.2.0, Nape 2.0.19. Seems to be an issue with static initialization order - creating a static CbType leads to ZPP_ID.CbType() being called without _CbType being initialized to 0 yet.

Somewhat related to #81 I guess. This has also been brought up in #77.

IBwWG commented 7 years ago

I'm getting this still with haxe 3.4.0, neko 2.1.0, and Nape 2.0.20, on linux64.

The output is slightly different in that it has a few extra lines about C:

Called from zpp_nape/callbacks/CbType.hx line 348
Called from nape/callbacks/CbType.hx line 179
Called from a C function
Called from nape/callbacks/CbType.hx line 198
Called from zpp_nape/callbacks/CbType.hx line 174
Called from a C function
Called from zpp_nape/callbacks/CbType.hx line 353
Called from zpp_nape/ID.hx line 186
Uncaught exception - Invalid operation (+)