Skip to content

Static slices create corrupted iterators #7617

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
drrb opened this issue Jul 6, 2013 · 9 comments
Closed

Static slices create corrupted iterators #7617

drrb opened this issue Jul 6, 2013 · 9 comments
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-macos Operating system: macOS

Comments

@drrb
Copy link

drrb commented Jul 6, 2013

Original bug report.

Version: 0.7
Platform: OSX (installed via Homebrew)

Running rust help displays an error.

$ rust help
The rust tool is a convenience for managing rust source code.
It acts as a shortcut for programs of the rust tool chain.

Usage:  rust <command> [arguments]

The commands are:

    build   compile rust source files
    run     build an executable, and run it
    test    build a test executable, and run it
    doc     generate documentation from doc comments
    pkg     download, build, install rust packages
    sketch  run a rust interpreter
    help    show detailed usage of a command
rust(99583,0x108ce3000) malloc: *** mmap(size=7522747388523884544) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Updated information (by @alexcrichton, 7-28-2013)

The problem for this was patched over in #8086, the behavior seen was that the static slice of Command structs would cause problems with iteration. It was determined that using iter() caused problems while not using the method and iterating directly worked just fine.

@Aatch
Copy link
Contributor

Aatch commented Jul 6, 2013

😕 WAT

@alexcrichton
Copy link
Member

I think this has to do with the static COMMANDS variable. This may have to do with some linkage thing somewhere. If you change the global to static mut (which changes how linkage stuff is set), then this runs just fine. I originally thought it may be the layout, but perhaps we're telling LLVM things about statics which aren't necessarily correct?

@agarie
Copy link

agarie commented Jul 15, 2013

Any idea of what might be causing this? I'm having the same problem. :(

@nicholasguyett
Copy link

I can confirm the exact same error. Same platform and version.

@arturmazurek
Copy link

Happens also when built from source on Release+Asserts build. What's interesting - didn't happen on Debug+Asserts build (./configure --enable-debug --disable-optimize{,-cxx,-llvm}).

@alexcrichton
Copy link
Member

I edited the title and the description to reflect the current state of affairs.

bors added a commit that referenced this issue Jul 28, 2013
#7617 

While the code that was there should've been perfectly fine (and seemingly is on linux at least) there seems to be some sort of weird interaction going on with statics and vectors. I couldn't get a smaller test case to reproduce that behaviour. The for loop in `rust::usage` seemingly just goes past the end of the vector thus getting garbage which it tries to pass to malloc somewhere down the line.

In any case, using a fixed length vector seems to mitigate this.
@cypher
Copy link
Contributor

cypher commented Jul 29, 2013

fe9929e seems to have fixed this, installing Rust via Homebrew using brew install rust --HEAD && rust no longer crashes for me.

@arturmazurek
Copy link

👍 doesn't crash for me either

@thestinger
Copy link
Contributor

It's a workaround, the issue is still unfixed.

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 3, 2021
…iraffate

Reference new diagnostic item docs in our docs :)

The title says it all. The rustc dev guide now has some information about diagnostic items that are worthwhile linking to 🙃

---

changelog: none
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. O-macos Operating system: macOS
Projects
None yet
Development

No branches or pull requests

8 participants