munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.88k stars 1.04k forks source link

OP_JUMP_IF_FALSE throwing Segfault. #1044

Closed rajeshmajumdar closed 2 years ago

rajeshmajumdar commented 2 years ago

For some reason, in emitJump() function in compiler.c, when I am calling emitByte(OP_JUMP_IF_FALSE) it is throwing a segfault error, while emitting any other opcode it's working just fine.

It's never reaching vm.c, I banged my head around for a week now I don't know what's going wrong here.

rajeshmajumdar commented 2 years ago

I am so stupid, the error was due to implementation in debug.c, it was at this line printf("%-16s %4d -> %d\n", name, offset, offset + 3 + sign * jump);. Here instead of %d\n it is suppose to be %n. Thanks to lldb.