mojo
mojo copied to clipboard
[BUG] Crash on iterating through Python dict with NumPy ndarray value
Bug description
Code snippet:
from python import Python
def main():
var np = Python.import_module("numpy")
var d = Python.dict()
d[42] = np.eye(10)
# meant to write d.items()
for x in d:
print(x[1].shape)
Running it crashes:
$ magic run mojo crash_items.mojo
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: /Users/carlo/hello-world/.magic/envs/default/bin/mojo crash_items.mojo
mojo crashed!
Please file a bug report.
[72967:1302362:20240922,182610.515462:WARNING in_range_cast.h:38] value -634136515 out of range
[72967:1302362:20240922,182610.518527:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)
It doesn't crash if I change the loop to
for x in d.items():
Steps to reproduce
Just run the code snippet.
$ magic run mojo crash_items.mojo
System information
- What OS did you do install Mojo on ?
macOS 14.6.1 (23G93), Macbook Air M2
- Provide version information for Mojo by pasting the output of `mojo -v`
$ mojo -v
mojo 24.5.0 (e8aacb95)
(hello-world)
- Provide Modular CLI version by pasting the output of
modular -v
modular -v
zsh: command not found: modular
(hello-world)
I followed the hello world example in the docs; not sure why there's no modular binary.