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] Function composition crash #111

Closed
afarnham opened this issue May 12, 2023 · 1 comment
Closed

[BUG] Function composition crash #111

afarnham opened this issue May 12, 2023 · 1 comment
Assignees
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@afarnham
Copy link

Bug Description

Function composition crashes with error: Execution was interrupted, reason: signal SIGSEGV: invalid address (fault address: 0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

I would expect to be able to call the composed function.

Steps to Reproduce

  1. Paste the following a cell
fn square(x: Int) -> Int:
    return x * x

fn incr(x: Int) -> Int:
    return x + 1

fn compose[A: AnyType, B: AnyType, C: AnyType](f: fn(A) -> B, g: fn(B) -> C) -> fn(A) capturing -> C:
    fn bar(a: A) -> C:
        return g(f(a))
    return bar

let incrsq = compose[Int, Int, Int](incr, square)
let v = incrsq(2)
print(v)
  1. Run the cell.

Context


11:devices:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
10:freezer:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
9:cpuset:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
8:pids:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
7:perf_event:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
6:cpu,cpuacct:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
5:memory:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
4:net_cls,net_prio:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
3:hugetlb:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
2:blkio:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod326bc94d_94c0_4508_bb3f_3cac351d8df0.slice/cri-containerd-a4e2b628060ae6451b74a121c757bf18ea73e5ad7a7ea262da1cd5a43f52dd24.scope
0::/
@afarnham afarnham added the bug Something isn't working label May 12, 2023
@Mogball Mogball self-assigned this May 22, 2023
@Mogball
Copy link

Mogball commented May 22, 2023

This is because the closure state is stack-allocated (which is not desirable). Closing in favour of #217

@Mogball Mogball closed this as completed May 22, 2023
@ematejska ematejska added the mojo-repo Tag all issues with this label label May 7, 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

3 participants