leonardt / pycoreir

Python bindings for coreir
BSD 3-Clause "New" or "Revised" License
10 stars 6 forks source link

Error in testing #155

Open shi27feng opened 3 years ago

shi27feng commented 3 years ago

Hi all, Does anyone encounter the same error as below? Thanks

❯ pytest
========================================================================== test session starts ===========================================================================
platform darwin -- Python 3.9.2, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/fengshi/Workspace/pycoreir
plugins: anyio-2.2.0
collected 31 items

tests/test_base.py ....                                                                                                                                            [ 12%]
tests/test_coreir.py .......                                                                                                                                       [ 35%]
tests/test_directedview.py .                                                                                                                                       [ 38%]
tests/test_genargs.py .                                                                                                                                            [ 41%]
tests/test_generator.py .s                                                                                                                                         [ 48%]
tests/test_inline.py .                                                                                                                                             [ 51%]
tests/test_lazy_dict.py Fatal Python error: Bus error

Current thread 0x000000010142bd40 (most recent call first):
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/coreir/util.py", line 55 in __iter__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/_collections_abc.py", line 849 in __iter__
  File "/Users/fengshi/Workspace/pycoreir/tests/test_lazy_dict.py", line 6 in test_namespace
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/python.py", line 183 in pytest_pyfunc_call
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/python.py", line 1641 in runtest
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 162 in pytest_runtest_call
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 255 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 311 in from_call
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 254 in call_runtest_hook
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 215 in call_and_report
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 126 in runtestprotocol
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 109 in pytest_runtest_protocol
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 348 in pytest_runtestloop
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 323 in _main
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 269 in wrap_session
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 316 in pytest_cmdline_main
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/config/__init__.py", line 162 in main
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/config/__init__.py", line 185 in console_main
  File "/Users/fengshi/miniforge3/envs/py3.9/bin/pytest", line 8 in <module>
[1]    49944 bus error  pytest
leonardt commented 3 years ago

Can you try running it with pytest -s? This should prevent pytest from capturing stdout, and may give us some more useful information to see what the error is.

shi27feng commented 3 years ago

Hi @leonardt Please see the below error massage

❯ pytest -s
============================= test session starts ==============================
platform darwin -- Python 3.9.2, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/fengshi/Workspace/pycoreir
plugins: anyio-2.2.0
collected 31 items

tests/test_base.py ....
tests/test_coreir.py Module: global.multiply_by_2
  Type: {'input':BitIn[8], 'output':Bit[9]}
  Def? No
Module: global.multiply_by_2
  Type: {'input':BitIn[8], 'output':Bit[9]}
  Def? Yes
  Def:
    Instances:
      adder : add8
    Connections:
      adder.in1 <=> self.input
      adder.in2 <=> self.input
      adder.out <=> self.output

=====================
  Def:
    Instances:
      adder : add8
    Connections:
      adder.in2 <=> self.input
      adder.out <=> self.output
      adder.in1 <=> self.input

  Def:
    Instances:
      adder : add8
    Connections:
      adder.in1 <=> self.input
      adder.in2 <=> self.input
      adder.out <=> self.output

=====================
Printer!
{"top":"global.multiply_by_2",
"namespaces":{
  "global":{
    "modules":{
      "add8":{
        "type":["Record",[
          ["in1",["Array",8,"BitIn"]],
          ["in2",["Array",8,"BitIn"]],
          ["out",["Array",9,"Bit"]]
        ]],
        "modparams":{"init":"Int", "test_param0":"Int", "test_param1":"Int"}
      },
      "multiply_by_2":{
        "type":["Record",[
          ["input",["Array",8,"BitIn"]],
          ["output",["Array",9,"Bit"]]
        ]],
        "instances":{
          "adder":{
            "modref":"global.add8",
            "modargs":{"init":["Int",5], "test_param0":["Int",1], "test_param1":["Int",0]}
          }
        },
        "connections":[
          ["self.input","adder.in1"],
          ["self.input","adder.in2"],
          ["self.output","adder.out"]
        ]
      }
    }
  }
}
}

.......
tests/test_directedview.py .
tests/test_genargs.py .
tests/test_generator.py Type: {'in0':BitIn[16], 'in1':BitIn[16], 'out':Bit[16]}
.s
tests/test_inline.py .
tests/test_lazy_dict.py Fatal Python error: Bus error

Current thread 0x0000000102b2bd40 (most recent call first):
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/coreir/util.py", line 55 in __iter__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/_collections_abc.py", line 849 in __iter__
  File "/Users/fengshi/Workspace/pycoreir/tests/test_lazy_dict.py", line 6 in test_namespace
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/python.py", line 183 in pytest_pyfunc_call
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/python.py", line 1641 in runtest
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 162 in pytest_runtest_call
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 255 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 311 in from_call
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 254 in call_runtest_hook
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 215 in call_and_report
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 126 in runtestprotocol
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/runner.py", line 109 in pytest_runtest_protocol
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 348 in pytest_runtestloop
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 323 in _main
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 269 in wrap_session
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/main.py", line 316 in pytest_cmdline_main
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/config/__init__.py", line 162 in main
  File "/Users/fengshi/miniforge3/envs/py3.9/lib/python3.9/site-packages/_pytest/config/__init__.py", line 185 in console_main
  File "/Users/fengshi/miniforge3/envs/py3.9/bin/pytest", line 8 in <module>
[1]    55634 bus error  pytest -s
leonardt commented 3 years ago

Hmm, I wonder if this is related to python3.9. I don't think we've tested that, could you try downgrading to python 3.8 and see if you still get the same error. Also, are you using a local build of coreir? Or are you using the version distributed with pip? We should first try to see if the pip release works, then we can look into what's going on with the local build. If the pip version isn't working then there is something to investigate there.

shi27feng commented 3 years ago

I was building with a local one since I am sure that the pip one is not supporting apple m1 architecture.

leonardt commented 3 years ago

Hmm, I think I may need to find access to an M1 VM to debug since there's not enough info here to see exactly what's going on. If possible, you could try running with lldb (e.g. lldb -- pytest) then run bt and post the backtrace, this might give some more info on where in the code it's running into an error.