CPP target crashes without any error messages

How to detect wrong dynamic access on cpp target.

For example:

var dn:Dynamic;

trace("test: " + dn.test);

There is a similar situation in my application, but I cannot find it because exception info not availabe.

Try adding -debug to your hxml and make sure you run the debug executable after (i.e. if your --main is Main then the exe you want is called Main-debug), for me this changes the error from Illegal instruction: 4 to

Called from hxcpp::__hxcpp_main
Called from _Main.Main_Fields_::main Main.hx line 4
Error : Null Object Reference

Let me know if that works or not; if it doesn’t change anything then another thing you could try is to enable sanitizers by adding c++ compiler flags. This is great for general runtime crashes with hxcpp but it’s more involved because we need to know about which c++ compiler you’re using (clang, msvc etc)

1 Like

I think the problem was something else.

As soon as I find the problem, I will open a new topic.

Cool, good luck! If you’re compiling hxcpp with clang you can add something like this to your main class

@:buildXml('
<target id="haxe">
	<compilerflag value="-fno-omit-frame-pointer" />
	<compilerflag value="-fsanitize=address" />
	<compilerflag value="-fsanitize=thread" />
</target>
')

To enable address and thread sanitizers

1 Like