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] Address Sanitizer builds crash irregularly #2428

Open
vrakesh opened this issue Apr 28, 2024 · 0 comments
Open

[BUG] Address Sanitizer builds crash irregularly #2428

vrakesh opened this issue Apr 28, 2024 · 0 comments
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.

Comments

@vrakesh
Copy link

vrakesh commented Apr 28, 2024

Bug description

I have been expermenting to learn Mojo pointers

Here is the example code I am testing with sanitizer build

filename: pointers.mojo
# Purpose of this code is to understand pointers in mojo

fn main():
    alias num_elements = 3
    var intp: Pointer[Int] = Pointer[Int].alloc(num_elements)
    # assign some values to int
    for i in range(num_elements):
        intp[i] = i
    var sum_int: Int = 0
    print("sum of")
    for i in range(num_elements):
        print(i)
        sum_int += intp[i]
    print("is", sum_int)
    intp.free()

Consecutive runs of a binary build with

mojo build --sanitize address pointers.mojo

produce the following output

$ ./pointers 
sum of
0
1
2
is 3
$ ./pointers 
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
Segmentation fault (core dumped)
$ ./pointers 
sum of
0
1
2
is 3

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

System information

- What OS did you do install Mojo on ?
Linux
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 24.2.1 (2f0dcf11)
- Provide Modular CLI version by pasting the output of `modular -v`
mojo 24.2.1 (2f0dcf11)
@vrakesh vrakesh added bug Something isn't working mojo Issues that are related to mojo labels Apr 28, 2024
@JoeLoser JoeLoser added the mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension. label Apr 28, 2024
@ematejska ematejska added the mojo-repo Tag all issues with this label label Apr 29, 2024
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 Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.
Projects
None yet
Development

No branches or pull requests

3 participants