[quickjs-devel] Stack overflow exception caused by signed to unsigned integer conversion
- From: Alexander Rodin <rodin.alexander@xxxxxxxxx>
- To: quickjs-devel@xxxxxxxxxxxxx
- Date: Fri, 9 Aug 2019 23:16:54 +0300
Hi!
Sometimes (in particular, when QuickJS is called from Rust code with debug
information enabled) the value of
ctx->stack_top - js_get_stack_pointer()
inside function js_check_stack_overflow becomes negative. But because it is
stored to a variable with unsigned type size_t, this
negative value is casted to a large positive integer and stack overflow
exception is thrown without a reason.
The attached patch fixes this problem by using signed type ptrdiff_t instead of
size_t to store the difference.
Best regards,
Alexander
Attachment:
stack-overflow-signed.patch
Description: Binary data
Other related posts:
- » [quickjs-devel] Stack overflow exception caused by signed to unsigned integer conversion - Alexander Rodin