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] Getting the value of a Optional[String] (None) causes segmentation fault #2655

Closed
osawyerr opened this issue May 14, 2024 · 3 comments
Closed
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@osawyerr
Copy link

osawyerr commented May 14, 2024

Bug description

Getting the value if a Optional[String] (None) causes segmentation fault

Steps to reproduce

fn main() :
    var val1 = 2
    var val2 = Optional[String](None)
 
    var val3 = val2.value # gives segmentation fault
    print("foo", "bar", "baz")
olo@MacBook-Pro mojo_demo % '/Users/olo/.modular/pkg/packages.modular.com_mojo/bin/mojo' '/Users/olo/Documents/Source/Repo/mojo_demo/main.mojo'
:0: error: caller input parameter #2 has type '!lit.lifetime' but callee expected type '!lit.lifetime<*(0,0)>'
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: /Users/olo/.modular/pkg/packages.modular.com_mojo/bin/mojo /Users/olo/Documents/Source/Repo/mojo_demo/main.mojo
1. Crash resolving decl body at loc("/Users/olo/Documents/Source/Repo/mojo_demo/main.mojo":1:4)
    >> fn main() :
          ^.......
    >> var val1 = 2
    >> var val2 = Optional[String](None)
    >>
    >> var val3 = val2.value
       .........................<
2. Crash parsing statement at loc("/Users/olo/Documents/Source/Repo/mojo_demo/main.mojo":5:5)
    >> var val3 = val2.value
           ^....................<
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 0x00000001042a6640 llvm_strlcpy + 51508
1 mojo 0x00000001042a492c llvm_strlcpy + 44064
2 mojo 0x00000001042a6d2c llvm_strlcpy + 53280
3 libsystem_platform.dylib 0x0000000183b8b584 _sigtramp + 56
4 mojo 0x0000000105960af0 mbedtls_version_get_number + 4932860
5 mojo 0x0000000105962fcc mbedtls_version_get_number + 4942296
6 mojo 0x000000010455e130 __jit_debug_register_code + 76324
7 mojo 0x000000010455faf4 __jit_debug_register_code + 82920
8 mojo 0x0000000104560294 __jit_debug_register_code + 84872
9 mojo 0x0000000104560378 __jit_debug_register_code + 85100
10 mojo 0x000000010458dc0c __jit_debug_register_code + 271616
11 mojo 0x000000010458f4f4 __jit_debug_register_code + 277992
12 mojo 0x00000001045a1478 __jit_debug_register_code + 351596
13 mojo 0x00000001045964b4 __jit_debug_register_code + 306600
14 mojo 0x00000001045ceec4 __jit_debug_register_code + 538552
15 mojo 0x00000001045cb620 __jit_debug_register_code + 524052
16 mojo 0x00000001045cb420 __jit_debug_register_code + 523540
17 mojo 0x0000000104572134 __jit_debug_register_code + 158248
18 mojo 0x00000001045801e4 __jit_debug_register_code + 215768
19 mojo 0x0000000104580634 __jit_debug_register_code + 216872
20 mojo 0x0000000104588930 __jit_debug_register_code + 250404
21 mojo 0x0000000104588b58 __jit_debug_register_code + 250956
22 mojo 0x00000001041ee400
23 mojo 0x00000001041ff624
24 mojo 0x00000001041e96dc
25 dyld 0x00000001837d20e0 start + 2360
mojo crashed!
Please file a bug report.
[81246:5085472:20240514,231453.458571:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)
zsh: segmentation fault '/Users/olo/.modular/pkg/packages.modular.com_mojo/bin/mojo'

System information

- What OS did you do install Mojo on ? = MacOS Apple Silicon M3
- Provide version information for Mojo by pasting the output of `mojo -v` = mojo 24.3.0 (9882e19d)
- Provide Modular CLI version by pasting the output of `modular -v` = modular 0.8.0 (39a426b5)
@osawyerr osawyerr added bug Something isn't working mojo-repo Tag all issues with this label labels May 14, 2024
@ematejska
Copy link
Collaborator

In the nightly build, this now errors out with:

error: TODO: partial application of member methods is not yet supported
    var val3 = val2.value # gives segmentation fault
               ^
mojo: error: failed to parse the provided Mojo source module

Copy link
Collaborator

Closing until that is implemented.

@ematejska ematejska closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
@ematejska
Copy link
Collaborator

You also need to call val2.value() instead of val2.value.

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
Projects
None yet
Development

No branches or pull requests

2 participants