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

All errors become WASM traps #2

Open
DavidPowell opened this issue Jun 28, 2020 · 7 comments
Open

All errors become WASM traps #2

DavidPowell opened this issue Jun 28, 2020 · 7 comments

Comments

@DavidPowell
Copy link

@DavidPowell DavidPowell commented Jun 28, 2020

Thanks for all the hard work making this package available.

I installed only one package with the command pip install yowasp-nextpnr-ice40-8k, on Windows 10 x64, Anaconda Python 3.7 (same result for 3.8). It installs yowasp_nextpnr_ice40_8k-0.0.post2625.dev9-py3-none-any.whl

I then run yowasp-nextpnr-ice40. It prints out the full list of command line options, then prints out the following error message:

  File "<my home>\miniconda3\lib\runpy.py", line 193, in _run_module_as_main                                                                 
    "__main__", mod_spec)                                                                                                                          
  File "<my home>\miniconda3\lib\runpy.py", line 85, in _run_code                                                                            
    exec(code, run_globals)                                                                                                                        
  File "<my home>\Miniconda3\Scripts\yowasp-nextpnr-ice40.exe\__main__.py", line 7, in <module>                                              
  File "<my home>\miniconda3\lib\site-packages\yowasp_nextpnr_ice40\bin\__init__.py", line 61, in run_nextpnr_ice40                          
    sys.exit(_run_wasm_app("nextpnr-ice40.wasm", argv))                                                                                            
  File "<my home>\miniconda3\lib\site-packages\yowasp_nextpnr_ice40\bin\__init__.py", line 34, in _run_wasm_app                              
    app.exports["_start"]()                                                                                                                        
  File "<my home>\miniconda3\lib\site-packages\wasmtime\_func.py", line 115, in __call__                                                     
    raise Trap.__from_ptr__(trap)                                                                                                                  
wasmtime._trap.Trap: wasm trap: unreachable                                                                                                        
wasm backtrace:                                                                                                                                    
  0: 0x168303 - <unknown>!<wasm function 2901>                                                                                                     
  1: 0x161621 - <unknown>!<wasm function 2823>                                                                                                     
  2: 0x16164e - <unknown>!<wasm function 2824>                                                                                                     
  3: 0x15192 - <unknown>!<wasm function 243>                                                                                                       
  4: 0x14cb5 - <unknown>!<wasm function 234>                                                                                                       
  5: 0xa2b9e - <unknown>!<wasm function 945>                                                                                                       
  6: 0xd4aa6 - <unknown>!<wasm function 1051>                                                                                                      
  7: 0xbd4a - <unknown>!<wasm function 62>                                                                                                         
  8: 0xd5ce1 - <unknown>!<wasm function 1054>                                                                                                      
  9: 0x16871d - <unknown>!<wasm function 2908>                                                                                                     
  10: 0x1687a5 - <unknown>!<wasm function 2910>                                                                                                    
  11: 0x168308 - <unknown>!<wasm function 2902>                                                                                                    
  12: 0x1768 - <unknown>!<wasm function 21>

where <my home> represents my windows home folder.

If I run pip install yowasp-nextpnr-ice40-all, then the error no longer occurs.

@whitequark
Copy link
Member

@whitequark whitequark commented Jun 28, 2020

What's the yowasp-nextpnr-ice40 command line you use?

@whitequark
Copy link
Member

@whitequark whitequark commented Jun 28, 2020

Ah, sorry, I didn't your comment carefully. That's expected behavior at the moment. Until WASM has support for C++ exceptions, all errors will end up in WASM traps.

@whitequark whitequark changed the title wasm trap error if only ice40-8k package is installed All errors become WASM traps Jun 28, 2020
@DavidPowell
Copy link
Author

@DavidPowell DavidPowell commented Jun 28, 2020

The original error is easily worked around, however it seems that yosys/nextpnr often generate C++ exceptions. For example, I ran nmigen's 01_blinky.py example (which required changing "led" to "user_led") and it failed when writing the blif file. Is this expected behaviour?

@whitequark
Copy link
Member

@whitequark whitequark commented Jun 28, 2020

Yep. Until WASM gets first-class exceptions I'm afraid that's what's going to happen. I tried to get it a bit better where possible, but the amount of hacks I'm willing to add (and the upstream is willing to accept) is limited...

@DavidPowell
Copy link
Author

@DavidPowell DavidPowell commented Jul 9, 2020

A note for anyone else finding that WASM traps are constantly generated.

In my previous comment, it seemed that C++ exceptions were generated very frequently, and I found that yowasp-nextpnr was unusable from nmigen. This was due to installing nmigen from pip (right now the pip version is ~5 months old).

Once I updated to the git version of nmigen, and now that YoWASP/yosys#1 is fixed, nmigen's blinky example now runs and uploads fine, rather than crashing during the writing of the blif file.

@whitequark
Copy link
Member

@whitequark whitequark commented Jul 9, 2020

Ah, interesting! I indeed have not tested with nmigen 0.2. Nmigen 0.3 is going to be released soon, so that should not be a problem anymore after that.

@whitequark
Copy link
Member

@whitequark whitequark commented Oct 8, 2021

This will be fixed when WebAssembly/wasi-sdk#198 is merged and exception handling support lands in wasmtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants