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

[BUG]: mojo crash: Assertion `addedNew && "duplicate argument name in signature"' failed. #1675

Closed
junweizeng opened this issue Jan 26, 2024 · 1 comment
Assignees
Labels
bug Something isn't working crash mojo Issues that are related to mojo mojo-lang Tag for all issues related to language. mojo-repo Tag all issues with this label

Comments

@junweizeng
Copy link
Contributor

Bug description

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

@value
struct a:
    var b
    var b
a()

Steps to reproduce

$ mojo build test.mojo
/path/to/test.mojo:5:1: error: TODO: expressions are not yet supported at the file scope level
a()
^
/path/to/test.mojo:4:5: error: invalid redefinition of 'b'
    var b
    ^
/path/to/test.mojo:3:5: note: previous definition here
    var b
    ^
/path/to/test.mojo:3:11: error: struct field declaration must have a type
    var b
          ^
mojo: /__w/modular/modular/KGEN/lib/MojoParser/OverloadFitness.cpp:817: static M::KGEN::LIT::OverloadFitness M::KGEN::LIT::OverloadFitness::evaluate(M::KGEN::LIT::LITSignatureType, const M::KGEN::LIT::OverloadSet &, const M::KGEN::LIT::CallOperands &, bool, M::KGEN::LIT::ExprEmitter &): Assertion `addedNew && "duplicate argument name in signature"' failed.
[10814:10814:20240126,124622.346936:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[10814:10814:20240126,124622.347117:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
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":1:1)
    >> @value
       ^.....
    >> struct a:
    >>     var b
    >>     var b
    >> a()
       ...<
2.      Crash parsing statement at loc("/path/to/test.mojo":5:1)
    >> a()
       ^..<
 #0 0x000055a6383aaee7 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x60fee7)
 #1 0x000055a6383a8abe (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x60dabe)
 #2 0x000055a6383ab5bf (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x6105bf)
 #3 0x00007f4667591520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f46675e59fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f4667591476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f46675777f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f466757771b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f4667588e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000055a6388a47f8 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xb097f8)
#10 0x000055a638899aaa (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xafeaaa)
#11 0x000055a6388a0408 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xb05408)
#12 0x000055a638853c01 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xab8c01)
#13 0x000055a6388452d9 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xaaa2d9)
#14 0x000055a63887b2bc (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xae02bc)
#15 0x000055a6388780d8 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xadd0d8)
#16 0x000055a638877f76 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xadcf76)
#17 0x000055a63881a443 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa7f443)
#18 0x000055a638831a19 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa96a19)
#19 0x000055a6387e991a (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa4e91a)
#20 0x000055a6387f60c6 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa5b0c6)
#21 0x000055a6387f5fb0 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa5afb0)
#22 0x000055a63a1777da (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x23dc7da)
#23 0x000055a63a17e1af (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x23e31af)
#24 0x000055a63a17e635 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x23e3635)
#25 0x000055a63a61b609 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x2880609)
#26 0x000055a63a61b879 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x2880879)
#27 0x000055a63a616554 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x287b554)
#28 0x000055a63a17cb50 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x23e1b50)
#29 0x000055a6387e9456 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa4e456)
#30 0x000055a6387e69aa (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa4b9aa)
#31 0x000055a6387e82b0 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa4d2b0)
#32 0x000055a6387d9cb2 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa3ecb2)
#33 0x000055a6387d87e5 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa3d7e5)
#34 0x000055a6387d8b60 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa3db60)
#35 0x000055a63835d5cf (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5c25cf)
#36 0x000055a63835fc6b (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5c4c6b)
#37 0x000055a63835a79a (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5bf79a)
#38 0x000055a638359122 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5be122)
#39 0x00007f4667578d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x00007f4667578e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x000055a63835892e (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5bd92e)
Aborted

System information

- Ubuntu 22.04.3 LTS (WSL 2)
- mojo 0.6.3 (f58f8b94)
- modular 0.3.1 (589ce200)
@junweizeng junweizeng added bug Something isn't working mojo Issues that are related to mojo labels Jan 26, 2024
@ematejska ematejska added mojo-lang Tag for all issues related to language. crash labels Feb 1, 2024
@laszlokindrat laszlokindrat self-assigned this Feb 8, 2024
@laszlokindrat
Copy link
Contributor

Thanks for opening the ticket! I was able to reproduce the crash; the fix will be available in an upcoming release. Please continue to open issues if you run into problems!

patrickdoc pushed a commit that referenced this issue May 2, 2024
… are present (#37063)

When duplicate field names are present, we throw an error, but don't
stop processing the `@value` decorator (or the rest of the struct body).
This patch ensures that decorator resolution checks if the struct fields
are resolved successfully, and terminates otherwise (since decorators
will eventually have to assume that the body of the struct has been
resolved successfully).

Closes #1675.

MODULAR_ORIG_COMMIT_REV_ID: 65d677597b98a63941845f877a9fc1d40c8b6c49
@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash mojo Issues that are related to mojo mojo-lang Tag for all issues related to language. mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

3 participants