Skip to content

Stack overflow when using recursive statics #17252

Closed
@veddan

Description

Normally when a static variable has a recursive the definition, the compiler issues an error. However, if the static is used (and not just defined) rustc overflows its stack.

This program causes a stack overflow:

static FOO: uint = FOO * 1;                                                                         

fn main() {                                                                                         
    let x: [u8,..FOO];                                                                              
} 

Stack trace:

#0    0x00007ffff64cc000 in rust_stack_exhausted () from /usr/local/lib/librustrt-4e7c5e5c.so
#1    0x00007ffff7546425 in __morestack () from /usr/local/lib/librustc-4e7c5e5c.so
#2    0x00007ffff6dd220d in middle::const_eval::eval_const_expr_partial::h11ede327256210699Mo () from /usr/local/lib/librustc-4e7c5e5c.so
....
#2586 0x00007ffff6dd220d in middle::const_eval::eval_const_expr_partial::h11ede327256210699Mo () from /usr/local/lib/librustc-4e7c5e5c.so
#2587 0x00007ffff7154294 in middle::typeck::astconv::ast_ty_to_ty::h12934078733027096147 () from /usr/local/lib/librustc-4e7c5e5c.so
#2588 0x00007ffff713ba14 in middle::typeck::check::GatherLocalsVisitor$LT$$x27a$C$$x20$x27tcx$GT$.Visitor$LT$$LP$$RP$$GT$::visit_local::hac083927a83885a8TnQ () from /usr/local/lib/librustc-4e7c5e5c.so
#2589 0x00007ffff713d7ca in visit::walk_block::h15602413499699722333 () from /usr/local/lib/librustc-4e7c5e5c.so
#2590 0x00007ffff713a453 in middle::typeck::check::check_fn::h1f6850cb24db919djvQ () from /usr/local/lib/librustc-4e7c5e5c.so
#2591 0x00007ffff71399c9 in middle::typeck::check::check_bare_fn::h83c6b77b92a9500dHkQ () from /usr/local/lib/librustc-4e7c5e5c.so
#2592 0x00007ffff7144a71 in middle::typeck::check::check_method_body::h87417f0ff66a2979R7Q () from /usr/local/lib/librustc-4e7c5e5c.so
#2593 0x00007ffff7132900 in middle::typeck::check::check_item::hf5c79816b6c27c066WQ () from /usr/local/lib/librustc-4e7c5e5c.so
#2594 0x00007ffff7134956 in visit::walk_item::h4472717221064912739 () from /usr/local/lib/librustc-4e7c5e5c.so
#2595 0x00007ffff71397a4 in middle::typeck::check::check_item_types::h792a27a56b24fe35GjQ () from /usr/local/lib/librustc-4e7c5e5c.so
#2596 0x00007ffff6b46246 in util::common::time::h7017450272318258908 () from /usr/local/lib/librustc-4e7c5e5c.so
#2597 0x00007ffff735eaa5 in middle::typeck::check_crate::hc8cbed21e0ad422eqOg () from /usr/local/lib/librustc-4e7c5e5c.so
#2598 0x00007ffff7422979 in driver::driver::phase_3_run_analysis_passes::ha948f4e333bb56e1bHu () from /usr/local/lib/librustc-4e7c5e5c.so
#2599 0x00007ffff741d43b in driver::driver::compile_input::h60c9b34042a1c1d73ru () from /usr/local/lib/librustc-4e7c5e5c.so
#2600 0x00007ffff74b326e in driver::run_compiler::h855c1a698770968a3dy () from /usr/local/lib/librustc-4e7c5e5c.so
#2601 0x00007ffff74b1475 in driver::main_args::closure.148494 () from /usr/local/lib/librustc-4e7c5e5c.so
#2602 0x00007ffff6b5ef38 in task::TaskBuilder$LT$S$GT$::try_future::closure.100359 () from /usr/local/lib/librustc-4e7c5e5c.so
#2603 0x00007ffff6b5ee43 in task::TaskBuilder$LT$S$GT$::spawn_internal::closure.100330 () from /usr/local/lib/librustc-4e7c5e5c.so
#2604 0x00007ffff68242f2 in task::spawn_opts::closure.8418 () from /usr/local/lib/libnative-4e7c5e5c.so
#2605 0x00007ffff652752c in rust_try_inner () from /usr/local/lib/librustrt-4e7c5e5c.so
#2606 0x00007ffff6527516 in rust_try () from /usr/local/lib/librustrt-4e7c5e5c.so
#2607 0x00007ffff64cc393 in unwind::try::h8584155988c4d0bcuId () from /usr/local/lib/librustrt-4e7c5e5c.so
#2608 0x00007ffff64cc22c in task::Task::run::h6c02ec598f069801fYc () from /usr/local/lib/librustrt-4e7c5e5c.so
#2609 0x00007ffff6824122 in task::spawn_opts::closure.8358 () from /usr/local/lib/libnative-4e7c5e5c.so
#2610 0x00007ffff64cddc3 in thread::thread_start::h964d785f09a9e637rid () from /usr/local/lib/librustrt-4e7c5e5c.so
#2611 0x00007ffff13dc0db in start_thread () from /lib64/libpthread.so.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions