segfault
Opened this issue · 0 comments
csaftoiu commented
On OSX:
$ g++ -DUNIX paq8pxd.cpp -o paq8pxd
...
$ touch foo.txt
$ ./paq8pxd -0 foo.txt
Creating archive foo.txt.paq8pxd7 with 1 file(s)...
File list (11 bytes)
Compressed from 11 to 16 bytes.
1/1 Filename: foo.txt (0 bytes)
Block segmentation:
Compressed from 0 to 0 bytes.
Total 0 bytes compressed to 26 bytes.
Time 0.00 sec, used 606476 bytes of memory
$ ./paq8pxd -1 foo.txt
Creating archive foo.txt.paq8pxd7 with 1 file(s)...
File list (11 bytes)
Segmentation fault: 11
$ ./paq8pxd -7 foo.txt
Creating archive foo.txt.paq8pxd7 with 1 file(s)...
File list (11 bytes)
Segmentation fault: 11
Full compile output and lldb
output in debug mode:
$ g++ -DUNIX -g paq8pxd.cpp -o paq8pxd
paq8pxd.cpp:2421:28: warning: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
cm.set(hash(++i,(buf(w)+(buf(2)-buf(w+1))>>1), 0));
~~~~~~^~~~~~~~~~~~~~~~~~~~
paq8pxd.cpp:2421:28: note: place parentheses around the '+' expression to silence this warning
cm.set(hash(++i,(buf(w)+(buf(2)-buf(w+1))>>1), 0));
^
( )
paq8pxd.cpp:3493:12: warning: array index 14 is past the end of the array (which contains 14 elements) [-Warray-bounds]
cm.set(cxt[14]);
^ ~~
paq8pxd.cpp:3480:3: note: array 'cxt' declared here
static U32 cxt[14]; // order 0-11 contexts
^
paq8pxd.cpp:3602:27: warning: '&' within '|' [-Wbitwise-op-parentheses]
if (filetype==TEXT) c=c2&0x1F|((c3&0x1F)<<5); else c=c2;
~~^~~~~~
paq8pxd.cpp:3602:27: note: place parentheses around the '&' expression to silence this warning
if (filetype==TEXT) c=c2&0x1F|((c3&0x1F)<<5); else c=c2;
^
( )
paq8pxd.cpp:3610:46: warning: '&' within '|' [-Wbitwise-op-parentheses]
m.set(bpos*256+((words<<bpos&255)>>bpos|d&255),2048);//, 256);
~~^~~~
paq8pxd.cpp:3610:46: note: place parentheses around the '&' expression to silence this warning
m.set(bpos*256+((words<<bpos&255)>>bpos|d&255),2048);//, 256);
^
( )
paq8pxd.cpp:3694:33: warning: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
pu=a.p(pr0, c0, 3)+7*pr0+4>>3, pz=failcount+1;
~~~~~~~~~~~~~~~~~~~~~^~~~
paq8pxd.cpp:3694:33: note: place parentheses around the '+' expression to silence this warning
pu=a.p(pr0, c0, 3)+7*pr0+4>>3, pz=failcount+1;
^
( )
paq8pxd.cpp:3708:45: warning: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
if (fails&255) pr =pt*6+pu +pv*11+pz*14 +16>>5;
~~~~~~~~~~~~~~~~~~~~~~^~~~~
paq8pxd.cpp:3708:45: note: place parentheses around the '+' expression to silence this warning
if (fails&255) pr =pt*6+pu +pv*11+pz*14 +16>>5;
^
( )
paq8pxd.cpp:3709:41: warning: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
else pr =pt*4+pu*5+pv*12+pz*11 +16>>5;
~~~~~~~~~~~~~~~~~~~~~~^~~~~
paq8pxd.cpp:3709:41: note: place parentheses around the '+' expression to silence this warning
else pr =pt*4+pu*5+pv*12+pz*11 +16>>5;
^
( )
In file included from paq8pxd.cpp:4659:
./wrtpre.cpp:1534:14: warning: enumeration values 'VARWORD' and 'NUMBER' not handled in switch [-Wswitch]
switch (wordType)
^
paq8pxd.cpp:4928:88: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
if ((type==TEXT || type==TXTUTF8) && (tmpsize<(len-256))) printf(" (wrt: %d)", tmpsize);
~~ ^~~~~~~
%ld
paq8pxd.cpp:4960:27: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
} else if ((type==BASE64) ) {
~~~~^~~~~~~~
paq8pxd.cpp:4960:27: note: remove extraneous parentheses around the comparison to silence this warning
} else if ((type==BASE64) ) {
~ ^ ~
paq8pxd.cpp:4960:27: note: use '=' to turn this equality comparison into an assignment
} else if ((type==BASE64) ) {
^~
=
paq8pxd.cpp:5349:43: warning: format specifies type 'long' but the argument has type 'int' [-Wformat]
printf("\nFile list (%ld bytes)\n", len);
~~~ ^~~
%d
paq8pxd.cpp:5355:52: warning: format specifies type 'long' but the argument has type 'int' [-Wformat]
printf("Compressed from %ld to %ld bytes.\n",len,en.size()-start);
~~~ ^~~
%d
12 warnings generated.
$ lldb -- ./paq8pxd -7 foo.txt
(lldb) target create "./paq8pxd"
Current executable set to './paq8pxd' (x86_64).
(lldb) settings set -- target.run-args "-7" "foo.txt"
(lldb) r
Process 14576 launched: './paq8pxd' (x86_64)
Creating archive foo.txt.paq8pxd7 with 1 file(s)...
File list (11 bytes)
Process 14576 stopped
* thread #1: tid = 0x12f0c6a, 0x0000000100025506 paq8pxd`dot_product(t=0x0000000100814610, w=0x00000001068c01b2, n=776) + 102 at paq8pxd.cpp:1187, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x0000000100025506 paq8pxd`dot_product(t=0x0000000100814610, w=0x00000001068c01b2, n=776) + 102 at paq8pxd.cpp:1187
1184 assert(n == ((n + 7) & -8));
1185 __m128i sum = _mm_setzero_si128 ();
1186 while ((n -= 8) >= 0) { // Each loop sums eight products
-> 1187 __m128i tmp = _mm_madd_epi16 (*(__m128i *) &t[n], *(__m128i *) &w[n]); // t[n] * w[n] + t[n+1] * w[n+1]
1188 tmp = _mm_srai_epi32 (tmp, 8); // (t[n] * w[n] + t[n+1] * w[n+1]) >> 8
1189 sum = _mm_add_epi32 (sum, tmp); // sum += (t[n] * w[n] + t[n+1] * w[n+1]) >> 8
1190 }
(lldb)