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

formatting recursive enums seg faults #3556

Closed
jesse99 opened this issue Sep 22, 2012 · 2 comments
Closed

formatting recursive enums seg faults #3556

jesse99 opened this issue Sep 22, 2012 · 2 comments
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone

Comments

@jesse99
Copy link
Contributor

jesse99 commented Sep 22, 2012

Getting a seg fault doing fmt!("%?", foo) when foo was constructed using a recursive enum.

This is with rust pulled from master on Sep 22, 2012.

@jesse99
Copy link
Contributor Author

jesse99 commented Sep 22, 2012

Here is a test case:

// rustc --test to_str.rs && ./to_str
extern mod std;
use io::{ReaderUtil, WriterUtil};

enum Token {
    Text(@~str),
    ETag(@~[~str], @~str),
    UTag(@~[~str], @~str),
    Section(@~[~str], bool, @~[Token], @~str, @~str, @~str, @~str, @~str),
    IncompleteSection(@~[~str], bool, @~str, bool),
    Partial(@~str, @~str, @~str),
}

#[cfg(test)]
fn check_strs(actual: &str, expected: &str) -> bool
{
    if actual != expected
    {
        io::stderr().write_line(fmt!("Found %s, but expected %s", actual, expected));
        return false;
    }
    return true;
}

#[test]
fn tester()
{
    assert check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")");
    assert check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")");

    let t = Text(@~"foo");
    let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo");
    let v = fmt!("%?", u);    // this is the line that causes the seg fault
    assert v.len() > 0;
}

@catamorphism
Copy link
Contributor

Appears to be fixed; queued up a test case to check in.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 4, 2024
move intrinsics tests into dedicated folder

And separate them from "shims" (which are for extern functions we link against).
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 4, 2024
move intrinsics tests into dedicated folder

And separate them from "shims" (which are for extern functions we link against).
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

2 participants