Skip to content

Instantly share code, notes, and snippets.

@pencilcheck
Created March 5, 2012 13:20
Show Gist options
  • Save pencilcheck/1978280 to your computer and use it in GitHub Desktop.
Save pencilcheck/1978280 to your computer and use it in GitHub Desktop.
#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
Copy link

(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)

@skull-squadron
Copy link

Also tried with passing a &stats (of type rs_stats_t) instead of NULL, no workey either. :rage4:

@pencilcheck
Copy link
Author

Try with fopen, it might be it!!

Compiled with
llvm-gcc test.c -lrsync -g3

touch old file
touch sigfile

./a.out

no errors

@skull-squadron
Copy link

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

@pencilcheck
Copy link
Author

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