Bug#822619: clang crashes when compiling a specific source file with clang std=c++14 test.cpp

Mike Bell ezuratechan at gmail.com
Mon Apr 25 17:25:31 UTC 2016


Package: clang
Version: 1:3.5-25
Severity: important

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
   * What was the outcome of this action?
   * What outcome did you expect instead?

*** End of the template - remove these template lines ***

Source code found to break gcc also breaks clang.
The source code that caused the crash is located at: https://ideone.com/J699eJ
Pasting below in case link becomes unusable.

Source was placed in file test.cpp and compiled with command:

clang -std=c++14 test.cpp

Link to output of command: https://www.reddit.com/r/programming/comments/4gcp9r/snippet_that_causes_g_to_hang_and_use_gigabytes/d2gr09p

Output is pasted below source code below:

// ====================

#include <stdio.h>
 
// tested on gcc-4.9.3 on linux gentoo amd64
// warning: compiling this will eat gigabytes of ram really fast so keep
// your CTRL-C ready
// compile with --std=c++14
 
struct v2f {
	float x=0, y=0; // must be =0 to reproduce (probably works with other vals)
};
 
namespace {
	struct foo {
		// declaring the array like this somehow bypasses the fact that 
		// v2f cannot be initialized with {0}
		static const size_t max_objects = 0xFFFF;
		size_t num_objects; // this is not necessary, just wanted to check if it still did it when not accessing bars
		v2f bars[max_objects * 255]; // the larger this array is, the longer it hangs for and the more memory it uses
	};
 
	foo f{0}; // must be initialized with {0} to reproduce
}
 
int main() {
	printf("%ld\n", f.num_objects);
}

// ====================

clang: error: unable to execute command: Killed
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://bugs.debian.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-5b3398.cpp
clang: note: diagnostic msg: /tmp/test-5b3398.sh
clang: note: diagnostic msg: 

********************


-- System Information:
Debian Release: 8.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.5.0-x86_64-linode65 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages clang depends on:
ii  clang-3.5  1:3.5-10

clang recommends no packages.

clang suggests no packages.

-- no debconf information



More information about the Pkg-llvm-team mailing list