Skip to content

Instantly share code, notes, and snippets.

@kripken
Last active December 18, 2015 23:28
Show Gist options
  • Save kripken/5861345 to your computer and use it in GitHub Desktop.
Save kripken/5861345 to your computer and use it in GitHub Desktop.
weird fuzz bug
24
46
40
41
$ ~/Dev/clang+llvm-3.2-x86-linux-ubuntu-12.04/bin/clang -O0 t245.c ; ./a.out
res = 1146
$ ~/Dev/clang+llvm-3.2-x86-linux-ubuntu-12.04/bin/clang -O2 t245.c ; ./a.out
res = 335544632
$ ~/Dev/emscripten/emcc -O2 t245.c --embed-file input.txt ; node a.out.js
res = 335544632
that is on linux. on mac, a report says clang -O2 gives the same
result as -O0, and only emcc -O2 is wrong. all tests are on
LLVM 3.2 release.
//
// t245.c
// Generated by Moh's fuzzer on Fri Jun 21 22:42:39 2013
//
// Intel Corporation
//
#include <stdio.h>
#define N 100
#define CS(a,n) checkSum((unsigned int*) a, n)
#define INIT(a,n,s) init((unsigned int*) a, n, s)
void init (unsigned int a[], unsigned int n, int seed)
{
unsigned int j;
for (j = 0; j < n; j++) {
a[j] = ((j % 2 == 0) ? seed+j : seed-j) % 101;
}
}
unsigned int checkSum (unsigned int a[], unsigned int n)
{
unsigned int j, sum;
sum = 0;
for (j = 0; j < n; j++) {
sum += ((j % 2 == 0) ? a[j] : -a[j]);
}
return sum;
}
int main()
{
FILE* INPUT = fopen ("input.txt", "r");
unsigned int ko=24, iq=46, k9=40, jm=41, res=31;
unsigned int er[N];
unsigned int *pm=&ko;
INIT (er, N, 90);
fscanf (INPUT, "%u %u %u %u", &ko, &iq, &k9, &jm);
ko = -(er[96]);
if (er[70] <= er[80]) {
for (iq = 1; iq < 44; ++iq) {
}
*pm += *pm;
}
// Test Loop Fusion
for (k9 = 2; k9 < 54; k9++) {
}
for (jm = 2; jm < 54; jm++) {
// Test Pointer Intensiveness
*pm = ko - k9;
pm = &er[jm+1];
*pm = er[jm-1];
pm = &er[jm];
*pm += er[jm+1];
*pm += *pm;
}
res = ko;
res += CS (er, N);
printf ("res = %u\n", res);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment