[quickjs-devel] SIBGUS when encoding large proto files

  • From: Simon CORSIN <simon@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Tue, 26 Nov 2019 15:24:47 -0500

Hey there,

We are using QuickJS alongside ProtobufJS for encoding/decoding protobuf
objects. I've been investigating a crash where it seems like the stack gets
corrupted in some cases after decoding and/or encoding a protobuf object.
The attached git contains some code which will deserialize/serialize a
proto message, increase its size progressively until it crashes. The crash
is native, it doesn't gracefully fail with a JS stackoverflow error. This
sample code also starts up the main qjs shim from qjs.c in a background
thread, since it triggers much quicker in that case (probably related to
the fact that the background thread will have a smaller stack size).

When running this sample code on my main machine, the crash is usually just
a stack overflow when recursively calling *__JS_FreeValueRT*. In our
Android production app, the behavior is a bit more random and it doesn't
always crash exactly when handling the protobuf message, it can be a little
bit after.

https://github.com/rFlex/QuickJS-debug

Just execute "*run.sh*". You can also just take the "*js*" directory and
run "*qjs --std index.js*" directly.

It's still unclear whether the problem is solely that JS_FreeValueRT itself
can stack overflow or if there is something else going.

Let me know if you need more information or help.

Thanks!
Simon

Other related posts: