Open mattj1 opened 5 years ago
I don't understand the exact details, but it seems you achieved reentrancy somehow, and this is not supported by wren.
Well, the assertion thinks this is happening, but if you look at the code it's not, so this is a bug.
I think it's due to the following code in wrenCall
, which leaves vm->apiStack
pointing somewhere:
vm->apiStack
seems to be only set to NULL
by wrenCall
itself, but the above program calls wrenInterpret
after the wrenCall
. That means that on the first call to a foreign method, it runs into the assertion even though in this case vm->apiStack
not being NULL did not mean it was already in a foreign call.
Either a different method must be used to allow access the call's return value, or there needs to be another place where vm->apiStack
is reset to NULL
(or the assertion needs to be changed).
There are other odd cases, related to io/libuv. A stack-trace could help to understand better what is going on.
Here's my stack trace:
__pthread_kill 0x00007fff7d65c2c6
pthread_kill 0x00007fff7d717bf1
abort 0x00007fff7d5c66a6
createForeign wren_vm.c:627
runInterpreter wren_vm.c:1200
wrenInterpret wren_vm.c:1449
main main.c:82
start 0x00007fff7d5213d5
start 0x00007fff7d5213d5
Stack trace looks like a corruptions/bug. Someone should try to reproduce with valgrind.
Hey, I'm new to Wren, and while trying to update IronWren to work with the latest Wren source, I noticed that some of the example code demonstrating the use of the Wren API was failing, but only when using the Debug library. I re-wrote the code in C to see if it was an issue with C# or whatever, but it turns out I could re-produce the problem: