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] segfault on Struct recursive methods #3141

Closed
Mathieu-Prouveur opened this issue Jun 28, 2024 · 1 comment
Closed

[BUG] segfault on Struct recursive methods #3141

Mathieu-Prouveur opened this issue Jun 28, 2024 · 1 comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@Mathieu-Prouveur
Copy link

Bug description

Recursive functions work but Structs with recursive methods crash with a segmentation fault

Steps to reproduce

@value
struct FactorialComputer:
    fn compute(self, depth: UInt8) -> UInt8:
        if depth == 0:
            return 1
        return depth * self.compute(depth - 1)

fn compute(depth: UInt8) -> UInt8:
        if depth == 1:
            return 1
        return depth * compute(depth - 1)


fn main():
    var a = FactorialComputer().compute(1)  # Segfault
    # var a = compute(1)  # Works
    print(a)

System information

- What OS did you do install Mojo on ?
Ubuntu 22.04.3 LTS (on windows via WSL)

- 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)
@Mathieu-Prouveur Mathieu-Prouveur added bug Something isn't working mojo-repo Tag all issues with this label labels Jun 28, 2024
Copy link
Collaborator

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 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                     0x0000000100a75be0 llvm_strlcpy + 55076
1  mojo                     0x0000000100a73f88 llvm_strlcpy + 47820
2  mojo                     0x0000000100a76280 llvm_strlcpy + 56772
3  libsystem_platform.dylib 0x000000019ce1f584 _sigtramp + 56
4  mojo                     0x0000000100f1c4e0 __jit_debug_register_code + 2114028
5  mojo                     0x0000000100e81b48 __jit_debug_register_code + 1480788
6  mojo                     0x0000000100e804bc __jit_debug_register_code + 1475016
7  mojo                     0x0000000101cd1b10 mbedtls_version_get_number + 43880
8  mojo                     0x0000000102032b38 mbedtls_version_get_number + 3586960
9  mojo                     0x0000000102033570 mbedtls_version_get_number + 3589576
10 mojo                     0x0000000102039030 mbedtls_version_get_number + 3612808
11 mojo                     0x0000000102038dac mbedtls_version_get_number + 3612164
12 libc++.1.dylib           0x000000019cd18548 std::__1::__assoc_sub_state::wait() + 56
13 mojo                     0x0000000102123d4c mbedtls_version_get_number + 4574628
14 mojo                     0x0000000102129574 mbedtls_version_get_number + 4597196
15 mojo                     0x00000001021292b0 mbedtls_version_get_number + 4596488
16 mojo                     0x000000010212934c mbedtls_version_get_number + 4596644
17 libsystem_pthread.dylib  0x000000019cdeef94 _pthread_start + 136
18 libsystem_pthread.dylib  0x000000019cde9d34 thread_start + 8
mojo crashed!
Please file a bug report.
[2433:1766357:20240710,155256.730500:WARNING in_range_cast.h:38] value -634136515 out of range
[2433:1766357:20240710,155256.734204:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)

@linear linear bot closed this as completed Jul 26, 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-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants