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?



It turns out i DID have an import loop, it just wasn’t in my main program. was importing from and vice versa.

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


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!

1 Like

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?

1 Like

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/ 
../../motoko-base/src/ warning [M0155], operator may trap for inferred type
Ext/ import error [M0003], file Ext/ must not depend on itself

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

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

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

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

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

1 Like

@claudio @ggreif thank you both for taking the time to follow-up on this.

I was able to recreate the problem. I simply commented out the “Route” type definition in the file and added an import statement for Please see below.

import Bool "mo:base/Bool";
import Text "mo:base/Text";
import Iter "mo:base/Iter";
import Principal "mo:base/Principal";
import Hash "mo:base/Hash";
import Trie "mo:base/Trie";
import TrieSet "mo:base/TrieSet";
import ExtRoute "Route";

module {  
  public type Route = ExtRoute.Route;
  //public type Route = {
  //  from : Text;
  //  msg : Nat;

Trying to build again gave me the same Rosetta Error. I am currently running DFX version 0.11.0

Thanks, we are trying to repro this locally. One more q. Do you have a dfx.json around? Last time I looked it was not in the repository.

Sorry about that. I will add the additional files this evening.

1 Like

Hi @LightningLad91
I’m on the languages team with @claudio and @ggreif (nice to meet you!)

I put an error reproducing fork here with a dfx.json file

We are tracking this issue internally. Thanks for bringing this up!


Hi @kentosugama nice to meet you too!

Thank you for addressing the issue :slight_smile: