fachat / xa65

6502/65816 cross assembler
http://www.floodgap.com/retrotech/xa/
56 stars 9 forks source link

Apparent memory corruption on 64-bit platform... #2

Closed peteArnt closed 10 years ago

peteArnt commented 10 years ago

While trying to run the xa test files, the following text is emmitted by XA before it exits: xa: malloc.c:2372: sysmalloc: Assertion `(oldtop == (((mbinptr) (((char ) &((av)->bins[((1) - 1) * 2])) - builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 (sizeof(size_t))) - 1)) & ~((2 (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long) oldend & pagemask) == 0)' failed. make: ** [default] Aborted

Platform: Linux Mint 17, 64-bit. GCC Version:4.8.2-19 (from Ubuntu repository)

Running valgrind on xa also generates interesting results:

$ ~/Downloads/xa65/xa/tests/cpp $ valgrind -v --leak-check=full --show-leak-kinds=all ../../xa over.asm ==6386== Memcheck, a memory error detector ==6386== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==6386== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info ==6386== Command: ../../xa over.asm ==6386== --6386-- Valgrind options: --6386-- -v --6386-- --leak-check=full --6386-- --show-leak-kinds=all --6386-- Contents of /proc/version: --6386-- Linux version 3.13.0-24-generic (buildd@batsu) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 --6386-- Arch and hwcaps: AMD64, amd64-cx16-lzcnt-rdtscp-sse3-avx --6386-- Page sizes: currently 4096, max supported 4096 --6386-- Valgrind library directory: /usr/lib/valgrind --6386-- Reading syms from /home/peter/Downloads/xa65/xa/xa --6386-- Reading syms from /lib/x86_64-linux-gnu/ld-2.19.so --6386-- Considering /lib/x86_64-linux-gnu/ld-2.19.so .. --6386-- .. CRC mismatch (computed 4cbae35e wanted 8d683c31) --6386-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.19.so .. --6386-- .. CRC is valid --6386-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux --6386-- Considering /usr/lib/valgrind/memcheck-amd64-linux .. --6386-- .. CRC mismatch (computed 37cdde19 wanted adc367dd) --6386-- object doesn't have a symbol table --6386-- object doesn't have a dynamic symbol table --6386-- Scheduler: using generic scheduler lock implementation. --6386-- Reading suppressions file: /usr/lib/valgrind/default.supp ==6386== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-6386-by-peter-on-??? ==6386== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-6386-by-peter-on-??? ==6386== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-6386-by-peter-on-??? ==6386== ==6386== TO CONTROL THIS PROCESS USING vgdb (which you probably ==6386== don't want to do, unless you know exactly what you're doing, ==6386== or are doing some strange experiment): ==6386== /usr/lib/valgrind/../../bin/vgdb --pid=6386 ...command... ==6386== ==6386== TO DEBUG THIS PROCESS USING GDB: start GDB like this ==6386== /path/to/gdb ../../xa ==6386== and then give GDB the following command ==6386== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=6386 ==6386== --pid is optional if only one valgrind process is running ==6386== --6386-- REDIR: 0x4019ca0 (strlen) redirected to 0x38068331 (???) --6386-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so --6386-- Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so .. --6386-- .. CRC mismatch (computed 329d6860 wanted c0186920) --6386-- object doesn't have a symbol table --6386-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so --6386-- Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so .. --6386-- .. CRC mismatch (computed 1fb85af8 wanted 2e9e3c16) --6386-- object doesn't have a symbol table ==6386== WARNING: new redirection conflicts with existing -- ignoring it --6386-- old: 0x04019ca0 (strlen ) R-> (0000.0) 0x38068331 ??? --6386-- new: 0x04019ca0 (strlen ) R-> (2007.0) 0x04c2e1a0 strlen --6386-- REDIR: 0x4019a50 (index) redirected to 0x4c2dd50 (index) --6386-- REDIR: 0x4019c70 (strcmp) redirected to 0x4c2f2f0 (strcmp) --6386-- REDIR: 0x401a9c0 (mempcpy) redirected to 0x4c31da0 (mempcpy) --6386-- Reading syms from /lib/x86_64-linux-gnu/libc-2.19.so --6386-- Considering /lib/x86_64-linux-gnu/libc-2.19.so .. --6386-- .. CRC mismatch (computed bbba420d wanted a133d70e) --6386-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.19.so .. --6386-- .. CRC is valid --6386-- REDIR: 0x4ec4bb0 (strcasecmp) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4ec6ea0 (strncasecmp) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4ec4380 (memcpy@GLIBC_2.2.5) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4ec2610 (rindex) redirected to 0x4c2da30 (rindex) --6386-- REDIR: 0xffffffffff600400 (???) redirected to 0x3806831d (???) --6386-- REDIR: 0x4ebeec0 (strcmp) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4f78110 (strcmp_ssse3) redirected to 0x4c2f1b0 (strcmp) --6386-- REDIR: 0x4eba5a0 (malloc) redirected to 0x4c2ab10 (malloc) --6386-- REDIR: 0x4ec3820 (strstr) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4ed9080 (strstr_sse2_unaligned) redirected to 0x4c31fa0 (strstr) --6386-- REDIR: 0x4ec0910 (strlen) redirected to 0x4c2e0e0 (strlen) --6386-- REDIR: 0x4ec0d80 (GI_strncmp) redirected to 0x4c2e930 (__GI_strncmp) --6386-- REDIR: 0x4ec3260 (GI_strstr) redirected to 0x4c32030 (strstr_sse2) --6386-- REDIR: 0x4ecb910 (strchrnul) redirected to 0x4c319b0 (strchrnul) --6386-- REDIR: 0x4ec0350 (strcpy) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4ed49e0 (strcpy_sse2_unaligned) redirected to 0x4c2e1c0 (strcpy) --6386-- REDIR: 0x4ecb700 (rawmemchr) redirected to 0x4c319f0 (rawmemchr) ==6386== Invalid write of size 1 ==6386== at 0x4E8D9AF: _IO_vfscanf (vfscanf.c:1095) ==6386== by 0x4EA88C6: vsscanf (iovsscanf.c:44) ==6386== by 0x4E94B16: sscanf (sscanf.c:32) ==6386== by 0x4057CD: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a979 is 0 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== Invalid write of size 1 ==6386== at 0x4E8DA5B: _IO_vfscanf (vfscanf.c:1180) ==6386== by 0x4EA88C6: vsscanf (iovsscanf.c:44) ==6386== by 0x4E94B16: sscanf (sscanf.c:32) ==6386== by 0x4057CD: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a97f is 6 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== Invalid read of size 1 ==6386== at 0x4C2DA44: rindex (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x4057EE: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a979 is 0 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== Invalid write of size 1 ==6386== at 0x4057F4: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a97e is 5 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== --6386-- REDIR: 0x4ebec70 (index) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4ebeca0 (__GI_strchr) redirected to 0x4c2db90 (GI_strchr) --6386-- REDIR: 0x4ec25d0 (strncpy) redirected to 0x4a25720 (_vgnU_ifunc_wrapper) --6386-- REDIR: 0x4ed5010 (strncpy_sse2_unaligned) redirected to 0x4c2e770 (__strncpy_sse2_unaligned) lda @$c0c0c0 over.h:line 10: 1012:65816 mode used/required error --6386-- REDIR: 0x4ebac40 (free) redirected to 0x4c2bd80 (free) over.c:line 14: 1006:Label 'buggy' not defined Break after 2 errors ==6386== ==6386== HEAP SUMMARY: ==6386== in use at exit: 356,108 bytes in 9 blocks ==6386== total heap usage: 12 allocs, 3 frees, 357,284 bytes allocated ==6386== ==6386== Searching for pointers to 9 not-freed blocks ==6386== Checked 91,696 bytes ==6386== ==6386== 0 bytes in 1 blocks are definitely lost in loss record 1 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x401E78: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 5 bytes in 1 blocks are still reachable in loss record 2 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x403587: ll_def (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x403E4E: l_def (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x40615E: t_conv (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x408A5D: t_p1 (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401A6A: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 6 bytes in 1 blocks are still reachable in loss record 3 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x403587: ll_def (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x403F48: l_search (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x406951: t_conv (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x408A5D: t_p1 (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401A6A: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 9 bytes in 1 blocks are still reachable in loss record 4 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 1,208 bytes in 1 blocks are still reachable in loss record 5 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x409F1A: alloc_file (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4011BF: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 40,000 bytes in 1 blocks are still reachable in loss record 6 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405881: pp_init (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401206: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 40,000 bytes in 1 blocks are still reachable in loss record 7 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x4036D4: ll_def (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x403F48: l_search (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x406951: t_conv (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x408A5D: t_p1 (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401A6A: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 74,880 bytes in 1 blocks are still reachable in loss record 8 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x4058C0: pp_init (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401206: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== 200,000 bytes in 1 blocks are still reachable in loss record 9 of 9 ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x409F30: alloc_file (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4011BF: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== LEAK SUMMARY: ==6386== definitely lost: 0 bytes in 1 blocks ==6386== indirectly lost: 0 bytes in 0 blocks ==6386== possibly lost: 0 bytes in 0 blocks ==6386== still reachable: 356,108 bytes in 8 blocks ==6386== suppressed: 0 bytes in 0 blocks ==6386== ==6386== ERROR SUMMARY: 70 errors from 5 contexts (suppressed: 0 from 0) ==6386== ==6386== 3 errors in context 1 of 5: ==6386== Invalid write of size 1 ==6386== at 0x4057F4: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a97e is 5 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== ==6386== 3 errors in context 2 of 5: ==6386== Invalid write of size 1 ==6386== at 0x4E8DA5B: _IO_vfscanf (vfscanf.c:1180) ==6386== by 0x4EA88C6: vsscanf (iovsscanf.c:44) ==6386== by 0x4E94B16: sscanf (sscanf.c:32) ==6386== by 0x4057CD: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a97f is 6 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== ==6386== 30 errors in context 3 of 5: ==6386== Invalid write of size 1 ==6386== at 0x4E8D9AF: _IO_vfscanf (vfscanf.c:1095) ==6386== by 0x4EA88C6: vsscanf (iovsscanf.c:44) ==6386== by 0x4E94B16: sscanf (sscanf.c:32) ==6386== by 0x4057CD: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a979 is 0 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== ==6386== 33 errors in context 4 of 5: ==6386== Invalid read of size 1 ==6386== at 0x4C2DA44: rindex (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x4057EE: pp_cpp (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x405E54: pgetline (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x4019CC: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== Address 0x524a979 is 0 bytes after a block of size 9 alloc'd ==6386== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6386== by 0x405906: pp_open (in /home/peter/Downloads/xa65/xa/xa) ==6386== by 0x401793: main (in /home/peter/Downloads/xa65/xa/xa) ==6386== ==6386== ERROR SUMMARY: 70 errors from 5 contexts (suppressed: 0 from 0)

fachat commented 10 years ago

Thanks for pointing that out. xa is an old beast. I have never tried it on 64bit (yet).