Skip to content

Segfault when wrapping an anon obj in more than one layer #718

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

Closed
lkuper opened this issue Jul 20, 2011 · 1 comment
Closed

Segfault when wrapping an anon obj in more than one layer #718

lkuper opened this issue Jul 20, 2011 · 1 comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@lkuper
Copy link
Contributor

lkuper commented Jul 20, 2011

The call to my_c.foo() in this program segfaults:

fn main() {

    obj a() {
        fn foo() -> int {
            ret 2;
        }
    }

    auto my_a = a();

    auto my_b = obj() {
        with my_a
    };

    assert (my_b.foo() == 2);

    auto my_c = obj() {
        with my_b
    };

    assert (my_c.foo() == 2);
}
@ghost ghost assigned lkuper Jul 20, 2011
lkuper added a commit that referenced this issue Jul 20, 2011
@lkuper
Copy link
Contributor Author

lkuper commented Jul 21, 2011

Poking around in gdb reveals that a forwarding fn is being called in an infinite loop. Two forwarding fns are being generated. In the executable I'm looking at now, the one for my_b.foo() is called forwarding_fn1 and the one for my_c.foo() is forwarding_fn13.

First, the call to my_b.foo() takes us to forwarding_fn1, which takes us to my_a.foo(). This works fine. Then, the call to my_c.foo() takes us to forwarding_fn13, which takes us to fowarding_fn1. But then we get stuck on forwarding_fn1.

So, we don't always get stuck on forwarding_fn1. We only seem to get stuck when we arrive at it via another forwarding fn. We call my_c.foo(); my_c protests and says "oh, no, I'm not self, my_b is!"; we head to my_b.foo(), but since my_c has already insisted that my_b is self, we don't hear my_b telling us that actually my_a is self. I'll look at this some more when I get a chance to talk about it with graydon.

@lkuper lkuper closed this as completed Jul 21, 2011
@lkuper lkuper reopened this Jul 21, 2011
@lkuper lkuper closed this as completed Aug 9, 2011
@lkuper lkuper removed their assignment Jun 16, 2014
bors pushed a commit to rust-lang-ci/rust that referenced this issue Oct 26, 2020
ZuseZ4 added a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

1 participant