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

Stack overflow in rustdoc using enum_primitive with a big enum #25295

Closed
nstoddard opened this issue May 11, 2015 · 5 comments · Fixed by #55568
Closed

Stack overflow in rustdoc using enum_primitive with a big enum #25295

nstoddard opened this issue May 11, 2015 · 5 comments · Fixed by #55568
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@nstoddard
Copy link

Running cargo doc on the following code results in a stack overflow:

#[macro_use] extern crate enum_primitive;

enum_from_primitive! {
pub enum Test {
    A1,A2,A3,A4,A5,A6,
    B1,B2,B3,B4,B5,B6,
    C1,C2,C3,C4,C5,C6,
    D1,D2,D3,D4,D5,D6,
    E1,E2,E3,E4,E5,E6,
    F1,F2,F3,F4,F5,F6,
    G1,G2,G3,G4,G5,G6,
    H1,H2,H3,H4,H5,H6,
    I1,I2,I3,I4,I5,I6,
    J1,J2,J3,J4,J5,J6,
    K1,K2,K3,K4,K5,K6,
    L1,L2,L3,L4,L5,L6,
    M1,M2,M3,M4,M5,M6,
    N1,N2,N3,N4,N5,N6,
    O1,O2,O3,O4,O5,O6,
    P1,P2,P3,P4,P5,P6,
    Q1,Q2,Q3,Q4,Q5,Q6,
    R1,R2,R3,R4,R5,R6,
    S1,S2,S3,S4,S5,S6,
    T1,T2,T3,T4,T5,T6,
    U1,U2,U3,U4,U5,U6,
    V1,V2,V3,V4,V5,V6,
    W1,W2,W3,W4,W5,W6,
    X1,X2,X3,X4,X5,X6,
    Y1,Y2,Y3,Y4,Y5,Y6,
    Z1,Z2,Z3,Z4,Z5,Z6,
}
}
thread '<unknown>' has overflowed its stack
Could not document `enum-test`.

With significantly fewer enum variants, it works. If I remove the use of enum_from_primitive!, it works.

This is breaking cargo doc on one of my PRs (PistonDevelopers/glfw-rs#316).

@nstoddard nstoddard changed the title Stack overflow when generating documentation using enum_primitive with a big enum Stack overflow in rustdoc using enum_primitive with a big enum May 11, 2015
@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 13, 2015
@mitaa
Copy link
Contributor

mitaa commented Jan 26, 2016

This seems to be fixed.

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 26, 2016
@nstoddard
Copy link
Author

In my tests, you now need to have around 460+ enum variants in order to get the stack overflow. Can we assume nobody will ever have that many?

@sanmai-NL
Copy link

@alexcrichton: should a test still be written for this?
Panicking is not correct, better would be that the number of variants is limited explicitly and that this is documented. Better still if there is no limit, of course.

@alexcrichton
Copy link
Member

In theory yeah if there's something that overflowed previously and no longer does, we should have a test for that :)

@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: not aware of a test yet

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 3, 2018
test that rustdoc doesn't overflow on a big enum

Adds a test to close rust-lang#25295. The test case depended on `enum_primitive` so I just basically pulled its source into an auxiliary file, is that the right way to do it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants