[LLVMbugs] [Bug 20020] New: miscompile at -O1 produces crashing program (postRA scheduler?)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 12 16:01:08 PDT 2014


            Bug ID: 20020
           Summary: miscompile at -O1 produces crashing program (postRA
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following C test case is a reduced version of

This program is crashing on both Linux x86-64 and OS X using clang trunk (v3.5)
like so:
$ ./clang -fmath-errno -O1 nbody_reduced.c -march=atom -lm
$ ./a.out 
Segmentation fault (core dumped)

I am suspicious of postRA scheduling because after I enabled postRA scheduling
for another target (btver2) and rebuilt clang, the program began crashing on
that target too. I don't see a way to toggle postRA scheduling via command-line
flags, but if that's possible, it would be much easier to test.

Any suggestions on how to isolate this fault?

$ cat nbody_reduced.c 
#include <math.h>

struct planet {
  double x, y;
  double vx, vy;
  double mass;

void advance(int nbodies, struct planet * bodies, double dt)
  int i, j;
  for (i = 0; i < nbodies; i++) {
    struct planet * b = &(bodies[i]);
    for (j = i + 1; j < nbodies; j++) {
      struct planet * b2 = &(bodies[j]);
      double dx = b->x - b2->x;
      double dy = b->y - b2->y;
      double distance = sqrt(dx * dx + dy * dy);
      double mag = dt / (distance * distance * distance);
      b->vx -= dx * b2->mass * mag;
      b->vy -= dy * b2->mass * mag;
  for (i = 0; i < nbodies; i++) {
    struct planet * b = &(bodies[i]);
    b->x += b->vx;
    b->y += 0.01 * b->vy;

int main()
  struct planet bodies;
  advance(1, &bodies, 0.01);
  return 0;

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140612/f2e25976/attachment.html>

More information about the llvm-bugs mailing list