8000 [BUG]: Crash when instantiating String with invalid pointer in constructor · Issue #1273 · modular/modular · GitHub
[go: up one dir, main page]

Skip to content
[BUG]: Crash when instantiating String with invalid pointer in constructor #1273
@ivellapillil

Description

@ivellapillil

Bug description

The following code crashes:

fn main():
    _ = String(String()._as_ptr())

and the following:


fn main():
    _ = String(DTypePointer[DType.int8].alloc(-1))

Crash dump:

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 tree.mojo
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                     0x000000010422afc0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  mojo                     0x0000000104229120 llvm::sys::RunSignalHandlers() + 112
2  mojo                     0x000000010422b65c SignalHandler(int) + 344
3  libsystem_platform.dylib 0x000000018772fa24 _sigtramp + 56
4  libsystem_platform.dylib 0x0000000280034068 _sigtramp + 4170204796
5  mojo                     0x00000001045db3e0 M::KGEN::ExecutionEngine::runProgram(llvm::StringRef, llvm::StringRef, llvm::function_ref<M::ErrorOrSuccess (void*)>) + 212
6  mojo                     0x0000000104185210 run(M::State const&) + 4052
7  mojo                     0x000000010416ee78 main + 1672
8  dyld                     0x00000001873850e0 start + 2360
[45025:1682840:20231111,154219.151946:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)

May be it should be validated and rejected at construction.

The following code works though:

fn main():
    _ = String(String("A")._as_ptr())
    _ = String(DTypePointer[DType.int8].alloc(0))

Steps to reproduce

See above

System information

System Version: macOS 14.1 (23B74)
Kernel Version: Darwin 23.1.0
Model Name: MacBook Pro
Model Identifier: MacBookPro18,3
Model Number: MKGP3SM/A
Chip: Apple M1 Pro
Total Number of Cores: 8 (6 performance and 2 efficiency)
Memory: 16 GB

mojo 0.5.0 (6e50a738)
modular 0.2.1 (5144fffe)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcrashmojoIssues that are related to mojomojo-repoTag all issues with this labelmojo-stdlibTag for issues related to standard library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0