[BUG]: Invalid code causes mojo crash
Nobody has claimed this yet.
- Dominant language
- Mojo
- Stars
- 29.8k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Bug description
Actual behavior
Source code:
from std.memory import Pointer
def main():
var my_val = 100
var my_p = Pointer(to=my_val)
print(my_p)
print(*my_p)
Please submit a bug report to Issues · modular/modular · GitHub and include the crash backtrace along with all the relevant source codes.
Stack dump:
0. Program arguments: mojo test_0b.mojo
Crash resolving decl body at loc(“/home/diaor/Documents/Mojo/mojo-project/test_0b.mojo”:3:5)
def main():
^
Crash parsing statement at loc(“/home/diaor/Documents/Mojo/mojo-project/test_0b.mojo”:8:5)
print(*my_p)
^
Crash ParamInf::inferForCall at loc(“/home/diaor/Documents/Mojo/mojo-project/test_0b.mojo”:8:5)
print(*my_p)
^
[826545:826546:20260604,172643.799882:ERROR directory_reader_posix.cc:42] opendir /home/diaor/Documents/Mojo/life/.pixi/envs/default/share/max/crashdb/attachments/84bfce90-37d9-499e-becd-d271814d3098: No such file or directory (2)
#0 0x000056377eb766ab (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/mojo+0x80926ab)
#1 0x000056377eb737ca (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/mojo+0x808f7ca)
#2 0x000056377eb772f7 (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/mojo+0x80932f7)
#3 0x00007fa84293d520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007fa842a1990d syscall ./misc/../sysdeps/unix/sysv/linux/x86_64/syscall.S:38:0
#5 0x00007fa842c23a23 (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/../lib/libAsyncRTMojoBindings.so+0xd2a23)
#6 0x00007fa84293d520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#7 0x000056378dd3bdd0
Segmentation fault
Expected behavior
Compiler reports error on this code
Steps to reproduce
- Please paste or attach the .mojo files that are needed to reproduce the issue.
- If you are able to reduce the reproduction steps to a small example, this would be much appreciated!
- Please quote the command line you used to compile and/or run the example.
- If you see a crash or an error message, please paste it in the "actual behavior" above.
- If using the Godbolt / Compiler Explorer, share the example link.
- Include anything else that might help us debug the issue. Your insights and observations are welcome!
System information
- Provide the system information by running
pixi info. - Provide version information for MAX (includes Mojo) by pasting the output of
pixi list max.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running mojo test_0b.mojo with the reproduced source and inspect the crash locations reported around main() and print(*my_p). Compare the compiler behavior with the expected diagnostic for invalid code; done means the input reports an error instead of crashing or producing a segmentation fault.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100