Description
I'm having a bizarre issue where JsDiagGetStackTrace()
returns an empty trace even when there's something on the stack. This only seems to happen on Linux and what's very strange is that it appears to depend on optimization settings; I can't reproduce it in an unoptimized build at all (this being strange because ChakraCore itself is a fully optimized shared-library build in all cases, so the optimization settings of the host shouldn't matter).
To verify there was indeed something on the stack, I gave my debugger the following code:
function doStuff()
{
print("Checkpoint 1");
debugger;
print("Checkpoint 2");
}
doStuff();
Running this code, execution pauses at the debugger statement but the backtrace is completely empty--and remains empty even as I step through the remainder of the code.
To rule out that this isn't a bug in one of my abstractions, I added some instrumentation at the point I actually retrieve the stack:
if (JsDiagGetStackTrace(&backtrace) != JsNoError)
return false;
JsPropertyIdRef propId;
JsValueRef propValue;
int length;
JsCreatePropertyId("length", 6, &propId);
JsGetProperty(backtrace, propId, &propValue);
JsGetValueType(propValue, &type);
JsNumberToInt(propValue, &length);
printf("%d: %d\n", type, length);
The output was 2: 0
(2
being JsNumber); so it seems that I've indeed been handed back a zero-length array. If I recompile the host with -g
instead of an optimization flag, this same code prints 2: 2
upon hitting the debugger statement. It's very, very strange.