modularml / mojo

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

[BUG] Did Mojo run into an endless loop? #2139

Open danny-su opened 7 months ago

danny-su commented 7 months ago

Bug description

I just opened a Mojo project containing some simple code like Hello Word. These Mojo processes didn't exit after I closed Cursor.

image

Steps to reproduce

N/A

System information

- What OS did you do install Mojo on ?
macOS: 14.4.1
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 24.2.0 (c2427bc5)
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.6.0 (04c05243)
ematejska commented 7 months ago

Does it exit when you run on the commandline?

danny-su commented 7 months ago

@ematejska I didn't run the mojo command manually at all.

ematejska commented 7 months ago

For debugging, could you run it on the command line and see if it exits and provide the source code? There is not enough information for us to debug this.

danny-su commented 7 months ago

@ematejska Here is the code I may have run:

from os.env import getenv
from python import Python
from buffer import Buffer
from buffer import Dim

fn main() raises:
    var np = Python.import_module("numpy")
    var a = np.array([1, 2, 3])
    print(a)
    alias MyBuffer = Buffer[DType.int32, Dim(1)]
    var b = MyBuffer()
    b.zero()

Output:

[Running] mojo run "/Users/danny/Downloads/demo/mojo/hello.mojo"
[1 2 3]
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 run /Users/danny/Downloads/demo/mojo/hello.mojo
#0 0x000000010052fd20 llvm_strlcpy (/Users/danny/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000d3d20)
#1 0x000000010052de80 llvm_strlcpy (/Users/danny/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000d1e80)
#2 0x00000001005303c0 llvm_strlcpy (/Users/danny/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000d43c0)
#3 0x0000000180deb584 (/usr/lib/system/libsystem_platform.dylib+0x180477584)
#4 0x0000000300006754 
#5 0x00000001008dde58 llvm_strlcpy (/Users/danny/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x100481e58)
#6 0x00000001004810e0 _mh_execute_header (/Users/danny/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000250e0)
#7 0x00000001004646bc _mh_execute_header (/Users/danny/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x1000086bc)
#8 0x0000000180a320e0 
0x103e8d300 crashed!
Please file a bug report.
[43774:6522375:20240405,080042.045005:WARNING in_range_cast.h:38] value -634136515 out of range
[43774:6522375:20240405,080042.050744:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)

[Done] exited with code=null in 1.021 seconds

PS: I am unsure if I used Buffer correctly, I always get crash exceptions.