Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] crash when passing offset DTypePointer into Tensor #3060

Open
forFudan opened this issue Jun 15, 2024 · 0 comments
Open

[BUG] crash when passing offset DTypePointer into Tensor #3060

forFudan opened this issue Jun 15, 2024 · 0 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label tensor

Comments

@forFudan
Copy link

forFudan commented Jun 15, 2024

Bug description

Mojo crashes when I pass an offset DTypePointer into Tensor constructor. The code goes as follows:

from tensor import Tensor
fn main() raises:
    var arr = DTypePointer[DType.int16].alloc(10)
    memset_zero(arr, 10)
    var p = arr.offset(1)
    print(arr)
    print(p)
    var ts = Tensor[DType.int16](2, p)
    print(ts)

The crash message goes as follows. Note that the correct results are still printed (first 3 lines) before the crash message.

0x1319fbbf0
0x1319fbbf2
Tensor([[0, 0]], dtype=int16, shape=2)
mojo(69571,0x1f330cc00) malloc: *** error for object 0x1319fbbf2: pointer being freed was not allocated
mojo(69571,0x1f330cc00) 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 -I ../NuMojo ndarray.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                          0x00000001048e4c24 llvm_strlcpy + 51480
1  mojo                          0x00000001048e2f10 llvm_strlcpy + 44036
2  mojo                          0x00000001048e52c4 llvm_strlcpy + 53176
3  libsystem_platform.dylib      0x000000018b503584 _sigtramp + 56
4  libsystem_pthread.dylib       0x000000018b4d2c20 pthread_kill + 288
5  libsystem_c.dylib             0x000000018b3dfa30 abort + 180
6  libsystem_malloc.dylib        0x000000018b2efdc4 malloc_vreport + 896
7  libsystem_malloc.dylib        0x000000018b2f3430 malloc_report + 64
8  libsystem_malloc.dylib        0x000000018b30d494 find_zone_and_free + 528
9  libKGENCompilerRTShared.dylib 0x000000010cdb3ff4 KGEN_CompilerRT_AlignedFree + 156
10 libKGENCompilerRTShared.dylib 0x0000000300004168 KGEN_CompilerRT_AlignedFree + 8374256144
11 mojo                          0x0000000104c79530 __jit_debug_register_code + 1041480
12 mojo                          0x000000010484556c
13 mojo                          0x0000000104844f60
14 mojo                          0x000000010482d738
15 dyld                          0x000000018b14a0e0 start + 2360
mojo crashed!
Please file a bug report.
[69573:7330656:20240616,001458.650690:WARNING in_range_cast.h:38] value -634136515 out of range
[69573:7330656:20240616,001458.654508:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)

Steps to reproduce

See bug description.

System information

- What OS did you do install Mojo on ?
 
Apple M2, MacOS 14.5 (23F79)
- Provide version information for Mojo by pasting the output of `mojo -v`
 
mojo 24.4.0 (2cb57382)
 
- Provide Modular CLI version by pasting the output of `modular -v`
 
modular 0.8.0 (39a426b5)
@forFudan forFudan added bug Something isn't working mojo-repo Tag all issues with this label labels Jun 15, 2024
@forFudan forFudan changed the title [BUG] crash when pass offset DTypePointer into Tensor [BUG] crash when passing offset DTypePointer into Tensor Jun 15, 2024
@JoeLoser JoeLoser added the tensor label Jun 18, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label tensor
Projects
None yet
Development

No branches or pull requests

2 participants