How to detect null access on cpp target. (multithreading)
For example:
public static var simpleMap:Map<String, Dynamic>;
static public function main() {
//simpleMap = new Map<String, Dynamic>();
sys.thread.Thread.create(() -> {
simpleMap.set("1", {
example : null
});
});
trace("OK");
while(true)
{
}
}
There is a similar situation in my application, but I cannot find it because exception info not available.
I updated the example, null exception does not show when it is a multi threading.
public static var simpleMap:Map<String, Dynamic>;
static public function main() {
//simpleMap = new Map<String, Dynamic>();
sys.thread.Thread.create(() -> {
simpleMap.set("1", {
example : null
});
});
trace("OK");
while(true)
{
}
}
class Main {
public static var simpleMap:Map<String, Dynamic>;
static public function main() {
//simpleMap = new Map<String, Dynamic>();
simpleMap.set("1", {
example : null
});
trace("OK");
while(true)
{
}
}
}
Output:
Called from hxcpp::__hxcpp_main
Called from Main::main Main.hx line 7
Error : Null Object Reference
Multi Threaded Source Code:
class Main {
public static var simpleMap:Map<String, Dynamic>;
static public function main() {
//simpleMap = new Map<String, Dynamic>();
sys.thread.Thread.create(() -> {
simpleMap.set("1", {
example : null
});
});
trace("OK");
while(true)
{
}
}
}
I am also looking for a solution to this. I have a thread running and randomly crash and I have no clue on what or where that cause it. Is there any news on this yet?