mojo icon indicating copy to clipboard operation
mojo copied to clipboard

Mojo hangs when calling `.1` on a struct

Open koaning opened this issue 1 year ago • 1 comments

Bug Description

I was following the tutorial and ran this code.

struct MyPair:
    var first: Int
    var second: Int

    # We use 'fn' instead of 'def' here - we'll explain that soon
    fn __init__(self&, first: Int, second: Int):
        self.first = first
        self.second = second

    fn __lt__(self, rhs: MyPair) -> Bool:
        return self.first < rhs.first or
              (self.first == rhs.first and
               self.second < rhs.second)

bar = MyPair(1, 2)

Then, due to fat fingers I ran this.

bar.1

And now ... the notebook is freezing. Should that happen?

Steps to Reproduce

Run above code in Jupyter environment.

Context

I can't run this in the current run, because the notebook is frozen. But on restart I get this:

%%python
import subprocess

subprocess.Popen(["cat", "/proc/self/cgroup"])
11:pids:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
10:hugetlb:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
9:devices:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
8:cpuset:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
7:blkio:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
6:freezer:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
5:memory:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
4:net_cls,net_prio:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
3:cpu,cpuacct:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
2:perf_event:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pode933f7da_a239_4255_abac_ea303b5b73f6.slice/cri-containerd-6a19f982a7ef533860a2ec149b3abf36098576554868c33860bd4a82d582dde3.scope
0::/

koaning avatar May 05 '23 15:05 koaning

Mhm. Interesting. On restart it also seems to run fine again?

koaning avatar May 05 '23 15:05 koaning

I am not able to reproduce this bug. bar.1 gives a parser error, so it's possible you hit an intermittent failure in the notebook environment, but I'm closing this for now until it pops up again.

Mogball avatar May 07 '23 10:05 Mogball