Created
March 5, 2012 13:20
-
-
Save pencilcheck/1978280 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <librsync.h> | |
int | |
main() | |
{ | |
FILE *base, *sig; | |
base = fopen("oldfile", "rb"); | |
sig = fopen("sigfile", "wb"); | |
if (rs_sig_file(base, sig, RS_DEFAULT_BLOCK_LEN, RS_DEFAULT_STRONG_LEN, NULL) == RS_DONE) | |
return -1; | |
else | |
return 0; | |
} |
skull-squadron
commented
Mar 5, 2012
librsync 0.9.7 was installed via port install librsync
gdb ./a.out
GNU gdb 6.3.50-20050815 (Apple version gdb-1752) (Sat Jan 28 03:02:46 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .... done
(gdb) run
Starting program: /Volumes/Users/barry/a.out
Already booted .zshenv
Reading symbols for shared libraries +++...warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/blocksort.o" - no debug information available for "blocksort.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/huffman.o" - no debug information available for "huffman.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/crctable.o" - no debug information available for "crctable.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/randtable.o" - no debug information available for "randtable.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/compress.o" - no debug information available for "compress.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/decompress.o" - no debug information available for "decompress.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/bzlib.o" - no debug information available for "bzlib.c".
.................................. done
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x000000007b84eef0
0x00007fff9499f398 in feof ()
(gdb)
(gdb) start
Breakpoint 1 at 0x100000e6e: file librsynctest.c, line 9.
Starting program: /Volumes/Users/barry/scratch/a.out
Already booted .zshenv
Reading symbols for shared libraries +++...warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/blocksort.o" - no debug information available for "blocksort.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/huffman.o" - no debug information available for "huffman.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/crctable.o" - no debug information available for "crctable.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/randtable.o" - no debug information available for "randtable.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/compress.o" - no debug information available for "compress.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/decompress.o" - no debug information available for "decompress.c".
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/bzlib.o" - no debug information available for "bzlib.c".
.................................. done
Breakpoint 1, main () at librsynctest.c:9
9 base = rs_file_open("oldfile", "rb");
(gdb) step
10 sig = rs_file_open("sigfile", "wb");
(gdb) step
11 if (rs_sig_file(base, sig, RS_DEFAULT_BLOCK_LEN, RS_DEFAULT_STRONG_LEN, NULL) == RS_DONE)
(gdb) step
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x000000007b84eef0
0x00007fff9499f398 in feof ()
(gdb)
Also tried with passing a &stats (of type rs_stats_t) instead of NULL, no workey either.
Try with fopen, it might be it!!
Compiled with
llvm-gcc test.c -lrsync -g3
touch old file
touch sigfile
./a.out
no errors
Confirmed: rs_sig_file in either arg seg faults. fopen does not. No confidence of actually working (needs more testing). Update: works on both gcc-4.2 and llvm-gcc
I see no errors and sigfile has something in it, that's my best guess for working state :P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment