Open amsokol opened 6 months ago
Reproduces with 24.3 in REPL and compiled.
v
is a UInt8
, not an array with three elements, and v[1]
triggers UB.
Reproduces with 24.3 in REPL and compiled.
I have two Apple laptops (M1 and M2) with the latest Sonoma and Mojo 24.3 installed. Fails on both.
v
is aUInt8
, not an array with three elements, andv[1]
triggers UB.
It fails when Mojo compiles code. It should not happen regardless of what code is compiled.
This code breaks Mojo playground compiler (https://docs.modular.com/mojo/playground) also:
fn main():
var v = UInt8[](0, 0, 0)
for i in range(2):
print("i = " + str(i))
v[i] = 0
Compile error:
mojo: /__w/modular/modular/third-party/llvm-project/llvm/include/llvm/ADT/SmallVector.h:304: llvm::SmallVectorTemplateCommon::reference llvm::SmallVectorTemplateCommon<M::KGEN::POP::DTypeValue>::operator[](llvm::SmallVectorTemplateCommon::size_type) [T = M::KGEN::POP::DTypeValue]: Assertion `idx < size()' 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 without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 mojo 0x0000555b5aec6217
1 mojo 0x0000555b5aec3dee
2 mojo 0x0000555b5aec68af
3 libc.so.6 0x00007fd5ad44c520
4 libc.so.6 0x00007fd5ad4a09fc pthread_kill + 300
5 libc.so.6 0x00007fd5ad44c476 raise + 22
6 libc.so.6 0x00007fd5ad4327f3 abort + 211
7 libc.so.6 0x00007fd5ad43271b
8 libc.so.6 0x00007fd5ad443e96
9 mojo 0x0000555b5c7797d2
10 mojo 0x0000555b5c71588f
11 mojo 0x0000555b5c714e34
12 mojo 0x0000555b5b52975e
13 mojo 0x0000555b5c5d1b1a
14 mojo 0x0000555b5c5d164c
15 mojo 0x0000555b5c5ce894
16 mojo 0x0000555b5d9c6a76
17 mojo 0x0000555b5d9c7101
18 mojo 0x0000555b5d9cc612
19 mojo 0x0000555b5d9cc70f
20 mojo 0x0000555b5b5468f8
21 mojo 0x0000555b5adf2787
22 libc.so.6 0x00007fd5ad4a3ee8
23 mojo 0x0000555b5b546b9b
24 mojo 0x0000555b5b546d25
25 mojo 0x0000555b5ae8f02c
26 mojo 0x0000555b5ae90311
27 libc.so.6 0x00007fd5ad49eac3
28 libc.so.6 0x00007fd5ad530850
Bug description
Steps to reproduce
build this code using "mojo build ./main_bug.mojo" main_bug.mojo:
System information