-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stack overflow for large witnesses #224
Conversation
function caml_wrap_exception(e) { | ||
if (e instanceof Array) return e; | ||
if (e instanceof globalThis.Error && caml_named_value('jsError')) | ||
return [0, caml_named_value('jsError'), e]; | ||
//fallback: wrapped in Failure | ||
return [0, caml_global_data.Failure, caml_string_of_jsstring(String(e))]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fixes that stack overflows used to be thrown as an array. it overrides the caml_wrap_exception
function from JSOO, which has a special case for stack overflows, which doesn't preserve the stack trace.
this simply removes the special case, and thus stack overflows end up in the second if
case, where we preserve the original error e
which can be later be re-thrown in JS.
} | ||
|
||
let typ (size_in_field_elements : int) : (Field.t array, field array) Typ.t = | ||
Typ { empty_typ with size_in_field_elements } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original implementation using Typ.array
was causing stack overflows in (at least) the check
function, because it operated on an OCaml list with a recursive function
companion for o1-labs/o1js#1334