Rosetta Error During Canister Build

Hello :wave:

I’ve encountered a Rosetta error while attempting to deploy a canister to the local replica. During the build, DFX will pause for about 5 minutes and then eventually return the following:


rosetta error: unexpectedly need to EmulateForward on a synchronous exception x86_rip=0x7fff2017ff6f arm_pc=0x7ffe94440320 num_insts=5 inst_index=3 x86 instruction bytes: 0x56415741e5894855 0x8941505354415541
zsh: trace trap  dfx deploy RoutingTable

The canister code can be found here.

I found a similar topic here, but after checking my import statements I don’t think that’s the issue.

What typically causes this sort of error to occur?

Thanks!

2 Likes

It turns out i DID have an import loop, it just wasn’t in my main program.

Route.mo was importing from Sub.mo and vice versa.

After removing the loop I was able to build the canister without delay.

2 Likes

Hi @LightningLad91, thanks for the report! I am glad you were able to resolve the problem, but as a compiler engineer I have a few questions:

  • do you use the most recent dfx?
  • can you describe the import structure you had that exhibited the crash?

I have opened Import loops should be caught · Issue #3389 · dfinity/motoko · GitHub, maybe you can post your answers there?

Thanks for your cooperation!

Interesting, we thought we had fixed this so motoko errors gracefully on cyclic imports. Could you report which version of moc or dfx you are using?

I’ve checked out the repo, reintroduced the new fixed cyclic dependency, but can’t seem to reproduce the hang and just get a cyclic import error on some of the files:

[nix-shell:~/uNFT-Prototype/src]$ moc --package base ../../motoko-base/src Ext/Route.mo 
../../motoko-base/src/Trie.mo:244.37-244.42: warning [M0155], operator may trap for inferred type
  Nat
Ext/Route.mo:17.1-17.17: import error [M0003], file Ext/Sub.mo must not depend on itself

[nix-shell:~/uNFT-Prototype/src]$ moc --package base ../../motoko-base/src Ext/Sub.mo 
../../motoko-base/src/Trie.mo:244.37-244.42: warning [M0155], operator may trap for inferred type
  Nat
Ext/Sub.mo:2.1-2.26: import error [M0003], file Ext/Route.mo must not depend on itself

[nix-shell:~/uNFT-Prototype/src]$ moc --package base ../../motoko-base/src Ext/ 
Registry.mo  Route.mo     Services.mo  Sub.mo       

[nix-shell:~/uNFT-Prototype/src]$ moc --package base ../../motoko-base/src Ext/Services.mo 

[nix-shell:~/uNFT-Prototype/src]$ moc --package base ../../motoko-base/src Ext/Registry.mo 
Ext/Registry.mo:1.1-1.46: import error [M0009], file "motoko/util/AccountIdentifier/lib.mo" does not exist
Ext/Registry.mo:2.1-2.36: import error [M0009], file "motoko/ext/Core/lib.mo" does not exist

But maybe I’m not trying to build the right code… (or the problem is higher up in dfx somehow).