Comments (2)
This appears to be a compiler / lifetime bug with the try/except block. When I run the above code on my setup, I get the following:
mojo(1451,0x1da6d1000) malloc: Double free of object 0x132a51660
mojo(1451,0x1da6d1000) malloc: *** set a breakpoint in malloc_error_break to debug
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 read-file.mojo
#0 0x0000000102f7f7c8 llvm_strlcpy (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1000bf7c8)
#1 0x0000000102f7db70 llvm_strlcpy (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1000bdb70)
#2 0x0000000102f7fe68 llvm_strlcpy (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1000bfe68)
#3 0x0000000183f21a24 (/usr/lib/system/libsystem_platform.dylib+0x18046da24)
#4 0x0000000183ef1cc0 (/usr/lib/system/libsystem_pthread.dylib+0x18043dcc0)
#5 0x0000000183dfda40 (/usr/lib/system/libsystem_c.dylib+0x180349a40)
#6 0x0000000183d14b08 (/usr/lib/system/libsystem_malloc.dylib+0x180260b08)
#7 0x0000000183d3424c (/usr/lib/system/libsystem_malloc.dylib+0x18028024c)
#8 0x0000000183d330a8 (/usr/lib/system/libsystem_malloc.dylib+0x18027f0a8)
#9 0x000000010615f4ec KGEN_CompilerRT_AlignedFree (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/lib/libKGENCompilerRTShared.dylib+0xb4ec)
#10 0x0000000280004358
#11 0x00000001033248a8 __jit_debug_register_code (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1004648a8)
#12 0x0000000102edea04 _mh_execute_header (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x10001ea04)
#13 0x0000000102ede3f8 _mh_execute_header (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x10001e3f8)
#14 0x0000000102ec6634 _mh_execute_header (/Users/john/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x100006634)
#15 0x0000000183b710e0
mojo crashed!
Please file a bug report.
[1453:7222129:20240615,151237.558235:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)
Removing the the print from the finally block produces the same crash
fn t1(filename : Path):
var bytes = List[UInt8]()
try:
with open(filename, "rb") as f:
bytes = f.read_bytes()
except:
pass
print(bytes[0],", ",bytes[1],", ",bytes[2],", ",bytes[3],", ",bytes[4],", ",bytes[5],", ",bytes[6],", ",bytes[7])
Interestingly, adding an except block with a return in it will get it working, when there is no finally block using bytes
:
fn t1(filename : Path):
var bytes = List[UInt8]()
try:
with open(filename, "rb") as f:
bytes = f.read_bytes()
except:
return
print(bytes[0],", ",bytes[1],", ",bytes[2],", ",bytes[3],", ",bytes[4],", ",bytes[5],", ",bytes[6],", ",bytes[7])
Introducing bytes
back into the finally block re-introduces the crash. This makes me think the error has something to do with bytes
being provided in the context of the finally block, even when one isn't used. The return in the unused except block appears to prevent this context from being created when we don't provide a finally block with the use of bytes
.
fn t1(filename : Path):
var bytes = List[UInt8]()
try:
with open(filename, "rb") as f:
bytes = f.read_bytes()
except:
return
finally:
print(bytes[0],", ",bytes[1],", ",bytes[2],", ",bytes[3],", ",bytes[4],", ",bytes[5],", ",bytes[6],", ",bytes[7])
print(bytes[0],", ",bytes[1],", ",bytes[2],", ",bytes[3],", ",bytes[4],", ",bytes[5],", ",bytes[6],", ",bytes[7])
System information
Apple M1 Pro, OS Sonoma 14.2.1
mojo 2024.6.1505 (238bad6d)
modular 0.8.0 (39a426b5)
from mojo.
that make sense.
from mojo.
Related Issues (20)
- [BUG] question about writing to file HOT 2
- [BUG] Cannot materialize a capturing closure
- [Docs] the "random" module should not be imported by default HOT 2
- [BUG] Index out of bound with nested list literals HOT 1
- [Feature Request] Allow __get_item__ calls to use a mix of colon slices and integers
- [BUG] Program Crash on generating simple data. HOT 1
- [BUG] errors on install HOT 2
- [Feature Request] [proposal] Fast but unsafe version of atol
- [BUG] Install Issue--Infected file warning (from Intego/Virusbarrier) HOT 2
- [BUG] Install Issue: Failed to run Script (mojo format) HOT 2
- [BUG] crash when attempting to use MAC mps when wrapping PyTorch
- [BUG] Possible SIMD[DType.bool, n] tested for truth in the stdlib where n > 1 HOT 5
- [BUG] Parser crash when a overload for a trait method is added
- [BUG] `Tensor` initialised from a list with wrong type shows weird behaviour
- [BUG] Parser crash when `moveinit` with wrong argument convention is defined while using `@value`
- [BUG] LSP & Mojo crashes when using Python.evaluate in a certain way + Bug Bounty(OpenAI credits) HOT 4
- [Feature Request] [stdlib] Add comp time `SIMD` range constructor
- [Feature Request] [stdlib] Add `assert_aborts()`
- Beğenilen
- [Modular CLI] Include mojo version in Max --version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mojo.