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

initializing internals failed #81

Open
lastmjs opened this issue Aug 31, 2023 · 2 comments
Open

initializing internals failed #81

lastmjs opened this issue Aug 31, 2023 · 2 comments

Comments

@lastmjs
Copy link

lastmjs commented Aug 31, 2023

I'm trying to get this to run in our development version of Azle that uses QuickJS under-the-hood. Here's the output I get when I just try to import mo from 'motoko/interpreter'; or import mo from 'motoko'; I've tried to increase the Rust stack size, but no matter how large I make it I can't get around these errors.

2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("internals:189.1-192.2: internal error, Failure(\"InternalError: stack overflow\")") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("\nLast environment:") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@ManagementCanister = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@add_cycles = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@blob_size = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@blob_vals = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@call_error = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@call_raw = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@call_succeeded = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@cancelTimer = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@create_actor_helper = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@cycles = 0") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@digits_dec = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@digits_hex = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@equal_array = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@getSystemRefund = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@ic00 = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@immut_array_get = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@immut_array_keys = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@immut_array_size = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@immut_array_vals = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@install_actor_helper = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@int16ToInt = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@int32ToInt = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@int64ToInt = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@int8ToInt = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@lastTimerId = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@left_pad = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@mut_array_get = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@mut_array_keys = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@mut_array_put = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@mut_array_size = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@mut_array_vals = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@nat16ToNat = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@nat32ToNat = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@nat64ToNat = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@nat8ToNat = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@new_async = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@nextExpiration = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@prune = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@refund = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@reset_cycles = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@reset_refund = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@setTimer = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@set_global_timer = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_chars = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_has_parens = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_needs_parens = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Blob = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Bool = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Char = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Float = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Int = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Int16 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Int32 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Int64 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Int8 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Nat = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Nat16 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Nat32 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Nat64 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Nat8 = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_Text = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_array = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_array_mut = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_num = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_option = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_of_variant = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@text_size = func") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@timer_helper = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("@timers = _") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("") 
2023-08-31 14:59:42.867840580 UTC: [Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] String("initializing internals failed")
@rvanasa
Copy link
Contributor

rvanasa commented Sep 1, 2023

Thanks for reaching out! It looks like the stack overflow is occurring in the JS engine, which is causing js_of_ocaml to handle this error as shown above. It's possible that QuickJS doesn't make the same stack optimizations as V8 / Spidermonkey, so it could be worth trying to increase the stack size as explained on this webpage.

Let me know if you need any further support from the Languages team, and I'll post this in our Slack channel in case anyone has other suggestions for how to get moc.js working in this environment.

@crusso
Copy link

crusso commented Sep 2, 2023

I'm don't know how QuickJS is implemented, but if it manages its own stack, then growing the Rust stack might not be so relevant and you should instead/also use QuickJS's JS_SetMaxStackSize()

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

No branches or pull requests

3 participants