llvm / llvm/circt

[PyCDE] ConcatOp of arrays causes crash

Open
#3,289 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

PyCDE
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

```
sel = hw.ConstantOp(types.i1, 0)
a = types.array(sel.type, 2)([sel, sel])
b = comb.ConcatOp(a, a)
```

This is invalid, but an error message should be displayed rather than a stack trace:

```
python3: /home/jodemme/circt/llvm/mlir/include/mlir/IR/Types.h:251: U mlir::Type::cast() const [U = mlir::IntegerType]: Assertion `isa()' failed.
#0 0x00007f80de16502a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/jodemme/circt/llvm/llvm/lib/Support/Unix/Signals.inc:565:11
#1 0x00007f80de1651db PrintStackTraceSignalHandler(void*) /home/jodemme/circt/llvm/llvm/lib/Support/Unix/Signals.inc:632:1
#2 0x00007f80de163876 llvm::sys::RunSignalHandlers() /home/jodemme/circt/llvm/llvm/lib/Support/Signals.cpp:103:5
#3 0x00007f80de165905 SignalHandler(int) /home/jodemme/circt/llvm/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007f80deab6520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007f80deb0aa7c __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
#6 0x00007f80deb0aa7c __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
#7 0x00007f80deb0aa7c pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
#8 0x00007f80deab6476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#9 0x00007f80dea9c7f3 abort ./stdlib/./stdlib/abort.c:81:7
#10 0x00007f80dea9c71b _nl_load_domain ./intl/./intl/loadmsgcat.c:1177:9
#11 0x00007f80deaade96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#12 0x00007f80da81d56a mlir::IntegerType mlir::Type::cast() const /home/jodemme/circt/llvm/mlir/include/mlir/IR/Types.h:0:3
#13 0x00007f80dcdb1d5e getTotalWidth(mlir::ValueRange) /home/jodemme/circt/lib/Dialect/Comb/CombOps.cpp:218:36
#14 0x00007f80dcdb1f42 circt::comb::ConcatOp::inferReturnTypes(mlir::MLIRContext*, llvm::Optional, mlir::ValueRange, mlir::DictionaryAttr, mlir::RegionRange, llvm::SmallVectorImpl&) /home/jodemme/circt/lib/Dialect/Comb/CombOps.cpp:249:12
#15 0x00007f80dcd9624d mlir::detail::InferTypeOpInterfaceInterfaceTraits::Model::inferReturnTypes(mlir::MLIRContext*, llvm::Optional, mlir::ValueRange, mlir::DictionaryAttr, mlir::RegionRange, llvm::SmallVectorImpl&) /home/jodemme/circt_build/tools/mlir/include/mlir/Interfaces/InferTypeOpInterface.h.inc:147:10
#16 0x00007f80da8398f3 mlirInferTypeOpInterfaceInferReturnTypes /home/jodemme/circt/llvm/mlir/lib/CAPI/Interfaces/Interfaces.cpp:72:14
#17 0x00007f80d76d533f mlir::python::PyInferTypeOpInterface::inferReturnTypes(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation) /home/jodemme/circt/llvm/mlir/lib/Bindings/Python/IRInterfaces.cpp:217:32
#18 0x00007f80d76d91f4 pybind11::cpp_function::cpp_function >, mlir::python::PyInferTypeOpInterface, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector > (mlir::python::PyInferTypeOpInterface::*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation)::operator()(mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation) const /home/jodemme/.local/lib/python3.10/site-packages/pybind11/include/pybind11/pybind11.h:109:59
#19 0x00007f80d76d8fe2 std::vector > pybind11::detail::argument_loader > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation>::call_impl >, pybind11::cpp_function::cpp_function >, mlir::python::PyInferTypeOpInterface, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector > (mlir::python::PyInferTypeOpInterface::*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation)&, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul, pybind11::detail::void_type>(mlir::python::PyInferTypeOpInterface&&, std::integer_sequence, pybind11::detail::void_type&&) && /home/jodemme/.local/lib/python3.10/site-packages/pybind11/include/pybind11/cast.h:1441:16
#20 0x00007f80d76d5c29 std::enable_if > >::value), std::vector > >::type pybind11::detail::argument_loader > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation>::call >, pybind11::detail::void_type, pybind11::cpp_function::cpp_function >, mlir::python::PyInferTypeOpInterface, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector > (mlir::python::PyInferTypeOpInterface::*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation)&>(pybind11::cpp_function::cpp_function >, mlir::python::PyInferTypeOpInterface, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector > (mlir::python::PyInferTypeOpInterface::*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation)&) && /home/jodemme/.local/lib/python3.10/site-packages/pybind11/include/pybind11/cast.h:1409:42
#21 0x00007f80d76d59e4 void pybind11::cpp_function::initialize >, mlir::python::PyInferTypeOpInterface, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector > (mlir::python::PyInferTypeOpInterface::*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), std::vector >, mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector >&&, mlir::python::PyInferTypeOpInterface (*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(pybind11::detail::function_call&)::operator()(pybind11::detail::function_call&) const /home/jodemme/.local/lib/python3.10/site-packages/pybind11/include/pybind11/pybind11.h:249:69
#22 0x00007f80d76d58c5 void pybind11::cpp_function::initialize >, mlir::python::PyInferTypeOpInterface, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector > (mlir::python::PyInferTypeOpInterface::*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), std::vector >, mlir::python::PyInferTypeOpInterface*, llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, pybind11::arg_v, char const*>(std::vector >&&, mlir::python::PyInferTypeOpInterface (*)(llvm::Optional > >, llvm::Optional, llvm::Optional > >, mlir::python::DefaultingPyMlirContext, mlir::python::DefaultingPyLocation), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, pybind11::arg_v const&, char const* const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) /home/jodemme/.local/lib/python3.10/site-packages/pybind11/include/pybind11/pybind11.h:224:21
#23 0x00007f80d75180d1 pybind11::cpp_function::dispatcher(_object*, _object*, _object*) /home/jodemme/.local/lib/python3.10/site-packages/pybind11/include/pybind11/pybind11.h:934:30
#24 0x00005594f29fd10e (/usr/bin/python3.10+0x15b10e)
#25 0x00005594f29f3bbb _PyObject_MakeTpCall (/usr/bin/python3.10+0x151bbb)
#26 0x00005594f2a0b2cb (/usr/bin/python3.10+0x1692cb)
#27 0x00005594f29e73ea _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x1453ea)
#28 0x00005594f29f2d54 _PyObject_FastCallDictTstate (/usr/bin/python3.10+0x150d54)
#29 0x00005594f2a07524 (/usr/bin/python3.10+0x165524)
#30 0x00005594f29f3f6b (/usr/bin/python3.10+0x151f6b)
#31 0x00007f80ddfc61c3 pybind11_meta_call /home/jodemme/.local/lib/python3.10/site-packages/pybind11/include/pybind11/detail/class.h:179:15
#32 0x00005594f29f3bbb _PyObject_MakeTpCall (/usr/bin/python3.10+0x151bbb)
#33 0x00005594f29ebfe1 _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x149fe1)
#34 0x00005594f2a0b13e (/usr/bin/python3.10+0x16913e)
#35 0x00005594f29e82de _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x1462de)
#36 0x00005594f29fd95c _PyFunction_Vectorcall (/usr/bin/python3.10+0x15b95c)
#37 0x00005594f29ebc1a _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x149c1a)
#38 0x00005594f29fd95c _PyFunction_Vectorcall (/usr/bin/python3.10+0x15b95c)
#39 0x00005594f29ebc1a _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x149c1a)
#40 0x00005594f29fd95c _PyFunction_Vectorcall (/usr/bin/python3.10+0x15b95c)
#41 0x00005594f29e6249 _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x144249)
#42 0x00005594f29fd95c _PyFunction_Vectorcall (/usr/bin/python3.10+0x15b95c)
#43 0x00005594f29e6249 _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x144249)
#44 0x00005594f29fd95c _PyFunction_Vectorcall (/usr/bin/python3.10+0x15b95c)
#45 0x00005594f29e6249 _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x144249)
#46 0x00005594f29e2956 (/usr/bin/python3.10+0x140956)
#47 0x00005594f2ad6906 PyEval_EvalCode (/usr/bin/python3.10+0x234906)
#48 0x00005594f2b03b88 (/usr/bin/python3.10+0x261b88)
#49 0x00005594f2afc86b (/usr/bin/python3.10+0x25a86b)
#50 0x00005594f2b038d5 (/usr/bin/python3.10+0x2618d5)
#51 0x00005594f2b02db8 _PyRun_SimpleFileObject (/usr/bin/python3.10+0x260db8)
#52 0x00005594f2b02ab3 _PyRun_AnyFileObject (/usr/bin/python3.10+0x260ab3)
#53 0x00005594f2af35ee Py_RunMain (/usr/bin/python3.10+0x2515ee)
#54 0x00005594f2ac98dd Py_BytesMain (/usr/bin/python3.10+0x2278dd)
#55 0x00007f80dea9dd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#56 0x00007f80dea9de40 call_init ./csu/../csu/libc-start.c:128:20
#57 0x00007f80dea9de40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#58 0x00005594f2ac97d5 _start (/usr/bin/python3.10+0x2277d5)
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/Dialect/Comb/CombOps.cpp at getTotalWidth and ConcatOp::inferReturnTypes, which the stack trace identifies. Re-run the PyCDE example with array operands, then verify that invalid ConcatOp input produces an error message rather than an assertion and stack trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.