-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE on extremely long string literal (larger than 4G) #61904
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
Comments
Took a quick look. We certainly have a restriction that any file can't be that large, because we use u32 for indexing. And looks like we never try to enforce it anywhere. I think the place to do that would be Do we have any way to panic without this being marked as ICE? I don't want to thread The "just panic" fix is here: matklad@8fd5b42 |
|
don't ICE on large files This is an extremely marginal error, so the cost of properly threading `Handler` everywhere just not seemed justified. However, it's useful to panic when we create a file, and not when we slice strings with overflown indexes somewhere in the guts of the compiler. For this reason, while we provide safe `try_new_source_file`, we don't change the existing public interface and just panic more or less cleanly. closes rust-lang#61904 r? @petrochenkov
I tried to compile the same thing in gcc and clang: #!/bin/sh
printf '#include <stdio.h>\nchar s[] = "' > hello.c
python -c 'print("h" * 4294967296)' >> hello.c
truncate -s -1 hello.c
printf '";' >> hello.c
cat >> hello.c << EOF
int main()
{
printf("%s\n", s);
return 0;
}
EOF
gcc hello.c -o hello_gcc
clang hello.c -o hello_clang # crash With gcc: % gdb hello_gcc
Reading symbols from a.out...(no debugging symbols found)...done.
(gdb) disas main
Dump of assembler code for function main:
0x0000000000001130 <+0>: push rbp
0x0000000000001131 <+1>: mov rbp,rsp
0x0000000000001134 <+4>: lea rdi,[rip+0x2ec6] # 0x4001 <s>
0x000000000000113b <+11>: call 0x1210 <puts@plt>
0x0000000000001140 <+16>: mov eax,0x0
0x0000000000001145 <+21>: pop rbp
0x0000000000001146 <+22>: ret
End of assembler dump.
(gdb) x/s 0x4001
0x4001 <s>: ""
(gdb) quit With clang: % clang hello.c
Stack dump:
0. Program arguments: /home/lzutao/.local/bin/clang-8 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmat
h-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /home/lzutao/.local/lib/clang/8.0.0 -internal-isystem /usr/local/include -internal-isystem /home/lzutao/.local/lib/clang/
8.0.0/include -internal-externc-isystem /home/lzutao/.local/include -internal-externc-isystem /usr/lib/gcc/x86_64-linux-gnu/6/include-fixed -internal-externc-isystem /usr/include -internal-externc-isystem /usr/local/include -internal-externc-isystem /usr/include/x86_64-l
inux-gnu -fdebug-compilation-dir /home/lzutao/forked/rust/check -ferror-limit 19 -fmessage-length 135 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/hello-27434e.o -x c hello.c -faddrsig
1. clang-8: error: unable to execute command: Alarm clock
clang-8: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 8.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/lzutao/.local/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-8: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/hello-943593.c
clang-8: note: diagnostic msg: /tmp/hello-943593.sh
clang-8: note: diagnostic msg:
******************** Meta% clang --version
clang version 8.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/lzutao/.local/bin
% gcc --version
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. EDIT: Opened https://bugs.llvm.org/show_bug.cgi?id=42301 |
I know that having huge literal in source is a bad idea, but it should not cause ICE :(
It looks like something overflowed.
Version:
rustc 1.37.0-nightly (4edff843d 2019-06-16) running on x86_64-unknown-linux-gnu
Command, output and backtrace:
Here is the generator of the source:
The text was updated successfully, but these errors were encountered: