-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Description
Running the rustc compiler inside of my (misbehaving?) emacs ends in an error as shown in the title. "Inside" means, M-x compilation ENTER rustc --verbose --version ENTER.
Reported to @Aatch on #[email protected]
The following C program is a small, low-dependency test case, that can show 3 different cases. See below for sample output.
/*
DESC This test program changes its own rlimits::RLIMIT_STACK to be
page-aligned or not depending on option, then execve() a
/usr/local/bin/rustc --verbose --version (installed via nightly).
COMPILE gcc -Wall main.c
RUN ./a.out e ; ./a.out n ; ./a.out
EXPECT './a.out e' reports thread '<unnamed>' panicked at 'failed to
allocate a guard page', when rust.git 44a287e63, Ubuntu 12.04.5
EXPECT './a.out n' runs with no errors.
EXPECT './a.out' will inherit whatever RLIMIT_STACK was set (like
inside an erroneous emacs).
DATE [2015-01-10 Sat 15:51]
*/
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/resource.h>
int main(int argc, char *argv[])
{
struct rlimit old = {0};
struct rlimit new = {0};
int j = 0;
for (j = 0; j < argc; ++j)
printf("argv[%d]: %s\n", j, argv[j]);
getrlimit(RLIMIT_STACK, &old);
printf("curr: %lu %lu\n", old.rlim_cur, old.rlim_max);
/* option: force normal case */
if (argc > 1 && argv[1][0] == 'n') {
old.rlim_cur = 8192 * 1024;
setrlimit(RLIMIT_STACK, &old);
}
/* option: force abnormal case */
if (argc > 1 && argv[1][0] == 'e') {
old.rlim_cur = 8720000; /* Ubuntu 12.04.5, Emacs 12.04.05 sample */
setrlimit(RLIMIT_STACK, &old);
}
getrlimit(RLIMIT_STACK, &new);
printf("2nd: %lu %lu\n", new.rlim_cur, new.rlim_max);
printf("Is RLIMIT_STACK 4KB page-aligned? %s\n",
(new.rlim_cur % 4096 == 0) ? "Yes": "NO!");
char *exe = "/usr/local/bin/rustc";
char *newargv[] = { exe, "--version", "--verbose", NULL };
char *newenv[] = { "RUST_BACKTRACE=1", NULL };
execve(exe, newargv, newenv);
exit(0);
}Output on the command line with sane RLIMIT_STACK:
+15470> ./a.out ; ./a.out e; ./a.out n
argv[0]: ./a.out
curr: 8388608 18446744073709551615
2nd: 8388608 18446744073709551615
Is RLIMIT_STACK 4KB page-aligned? Yes
rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)
binary: rustc
commit-hash: 44a287e6eb22ec3c2a687fc156813577464017f7
commit-date: 2015-01-08 17:03:40 -0800
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly
argv[0]: ./a.out
argv[1]: e
curr: 8388608 18446744073709551615
2nd: 8720000 18446744073709551615
Is RLIMIT_STACK 4KB page-aligned? NO!
thread '<unnamed>' panicked at 'failed to allocate a guard page', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:109
stack backtrace:
1: 0x7f78a55fd850 - sys::backtrace::write::h5b05e7b061a35107Czt
2: 0x7f78a561fa60 - failure::on_fail::h1e9b7e3de59488d1aPz
3: 0x7f78a558d5e0 - rt::unwind::begin_unwind_inner::h23dcfb4c37870bd62tz
4: 0x7f78a558d530 - rt::unwind::begin_unwind::h14463498374571830842
5: 0x7f78a5621840 - rt::lang_start::hf37c6346d533f5c0mJz
6: 0x7f78a5160680 - __libc_start_main
7: 0x0 - <unknown>
You've met with a terrible fate, haven't you?
fatal runtime error: Could not unwind stack, error = 5
zsh: illegal hardware instruction (core dumped) ./a.out e
argv[0]: ./a.out
argv[1]: n
curr: 8388608 18446744073709551615
2nd: 8388608 18446744073709551615
Is RLIMIT_STACK 4KB page-aligned? Yes
rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)
binary: rustc
commit-hash: 44a287e6eb22ec3c2a687fc156813577464017f7
commit-date: 2015-01-08 17:03:40 -0800
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly
Output inside of my misbehaving emacs:
-*- mode: compilation; default-directory: "~/projects/concepts/rust/debug1/" -*-
Compilation started at Sat Jan 10 16:01:40
gcc -Wall main.c && ./a.out ; ./a.out e ;./a.out n
argv[0]: ./a.out
curr: 8720000 18446744073709551615
2nd: 8720000 18446744073709551615
Is RLIMIT_STACK 4KB page-aligned? NO!
thread '<unnamed>' panicked at 'failed to allocate a guard page', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:109
stack backtrace:
1: 0x7fe3a5fd1850 - sys::backtrace::write::h5b05e7b061a35107Czt
2: 0x7fe3a5ff3a60 - failure::on_fail::h1e9b7e3de59488d1aPz
3: 0x7fe3a5f615e0 - rt::unwind::begin_unwind_inner::h23dcfb4c37870bd62tz
4: 0x7fe3a5f61530 - rt::unwind::begin_unwind::h14463498374571830842
5: 0x7fe3a5ff5840 - rt::lang_start::hf37c6346d533f5c0mJz
6: 0x7fe3a5b34680 - __libc_start_main
7: 0x0 - <unknown>
You've met with a terrible fate, haven't you?
fatal runtime error: Could not unwind stack, error = 5
argv[0]: ./a.out
argv[1]: e
curr: 8720000 18446744073709551615
2nd: 8720000 18446744073709551615
Is RLIMIT_STACK 4KB page-aligned? NO!
thread '<unnamed>' panicked at 'failed to allocate a guard page', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:109
stack backtrace:
1: 0x7f0de3f56850 - sys::backtrace::write::h5b05e7b061a35107Czt
2: 0x7f0de3f78a60 - failure::on_fail::h1e9b7e3de59488d1aPz
3: 0x7f0de3ee65e0 - rt::unwind::begin_unwind_inner::h23dcfb4c37870bd62tz
4: 0x7f0de3ee6530 - rt::unwind::begin_unwind::h14463498374571830842
5: 0x7f0de3f7a840 - rt::lang_start::hf37c6346d533f5c0mJz
6: 0x7f0de3ab9680 - __libc_start_main
7: 0x0 - <unknown>
You've met with a terrible fate, haven't you?
fatal runtime error: Could not unwind stack, error = 5
argv[0]: ./a.out
argv[1]: n
curr: 8720000 18446744073709551615
2nd: 8388608 18446744073709551615
Is RLIMIT_STACK 4KB page-aligned? Yes
rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)
binary: rustc
commit-hash: 44a287e6eb22ec3c2a687fc156813577464017f7
commit-date: 2015-01-08 17:03:40 -0800
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly
Compilation finished at Sat Jan 10 16:01:41
Metadata
Metadata
Assignees
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.