Skip to content
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

Merged
merged 4 commits into from
Dec 18, 2023
Merged

Conversation

mitschabaude
Copy link
Member

@mitschabaude mitschabaude commented Dec 18, 2023

companion for o1-labs/o1js#1334

Comment on lines +7 to +13
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))];
}
Copy link
Member Author

@mitschabaude mitschabaude Dec 18, 2023

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 }
Copy link
Member Author

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

@mitschabaude mitschabaude merged commit bf32d1a into main Dec 18, 2023
1 check passed
@mitschabaude mitschabaude deleted the fix/stack-overflow branch December 18, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants