modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
22.97k stars 2.59k forks source link

[BUG]: mojo crash: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed. #1853

Open junweizeng opened 7 months ago

junweizeng commented 7 months ago

Bug description

mojo crashes on the following code (i.e. test.mojo).

trait a(CollectionElement):

@value
struct b:
    var c: a

Steps to reproduce

$ mojo build test.mojo
/path/to/test.mojo:3:1: error: expected body statements; use 'pass' if none is required
@value
^
mojo: /__w/modular/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From &) [To = M::KGEN::LIT::FuncOp, From = M::KGEN::LIT::ASTDecl]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0.  Program arguments: mojo build test.mojo
1.  Crash resolving decl body at loc("/path/to/test.mojo":4:1)
    >> struct b:
       ^........
    >>     var c: a
       ............<
 #0 0x000055eb67eaee47 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x62ae47)
 #1 0x000055eb67eaca1e (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x628a1e)
 #2 0x000055eb67eaf51f (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x62b51f)
 #3 0x00007f3511454520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f35114a8a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f35114a8a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f35114a8a7c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f3511454476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f351143a7f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f351143a71b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f351144be96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000055eb6834eb6d (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xacab6d)
#12 0x000055eb683504df (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xacc4df)
#13 0x000055eb6835b525 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xad7525)
#14 0x000055eb6835c166 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xad8166)
#15 0x000055eb682ff1ee (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa7b1ee)
#16 0x000055eb683454c4 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xac14c4)
#17 0x000055eb683472a7 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xac32a7)
#18 0x000055eb682d5af6 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa51af6)
#19 0x000055eb682e7563 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa63563)
#20 0x000055eb682d2f99 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa4ef99)
#21 0x000055eb682d648c (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa5248c)
#22 0x000055eb682ea92a (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa6692a)
#23 0x000055eb682eafc8 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa66fc8)
#24 0x000055eb68298cfb (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa14cfb)
#25 0x000055eb68299059 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa15059)
#26 0x000055eb67e57e0f (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5d3e0f)
#27 0x000055eb67e5a23b (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5d623b)
#28 0x000055eb67e54ddf (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5d0ddf)
#29 0x000055eb67e5365d (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5cf65d)
#30 0x00007f351143bd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007f351143be40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007f351143be40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x000055eb67e52fae (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5cefae)

System information

- Ubuntu 22.04 LTS
- mojo 24.1.0 (55ec12d6)
- modular 0.5.1 (1b608e3d)
soraros commented 4 months ago

Doesn't reproduce on the latest nightly.

Brian-M-J commented 3 months ago

@junweizeng Since this doesn't crash anymore, can the issue be closed?