RsyncProject / rsync

An open source utility that provides fast incremental file transfer. It also has useful features for backup and restore operations among many other use cases.
https://rsync.samba.org
Other
2.92k stars 339 forks source link

UBSAN failures in test suite (part 2) #429

Open thesamesam opened 1 year ago

thesamesam commented 1 year ago

Followup to https://github.com/WayneD/rsync/issues/427. Testing with https://github.com/WayneD/rsync/pull/428 applied to avoid false positives from alignment (b/c testing on amd64).

Built with ./configure CC=clang-15 CFLAGS="-O2 -fsanitize=undefined -ggdb3" LDFLAGS="-fsanitize=undefined -ggdb3" --disable-md2man.

I see the following failures with Clang 15 (this is an excerpt, the full log is here: rsync-tests.log):

[...]
----- ssh-basic log ends
FAIL    ssh-basic
----- symlink-ignore log follows
Testing for symlinks using 'test -h'
skipping non-regular file "absolute"
skipping non-regular file "dangling"
skipping non-regular file "relative"
skipping non-regular file "unsafe"
lib/pool_alloc.c:103:9: runtime error: addition of unsigned offset to 0x7fa33c802030 overflowed to 0x7fa33c802010
    #0 0x55afe2e80c3a in pool_destroy /home/sam/git/rsync/lib/pool_alloc.c:103:9
    #1 0x55afe2dc0acf in flist_free /home/sam/git/rsync/flist.c:2956:3
    #2 0x55afe2dca1fd in check_for_finished_files /home/sam/git/rsync/generator.c:2218:3
    #3 0x55afe2dd1b43 in generate_files /home/sam/git/rsync/generator.c:2356:3
    #4 0x55afe2df9d16 in do_recv /home/sam/git/rsync/main.c:1114:2
    #5 0x55afe2df74c7 in do_server_recv /home/sam/git/rsync/main.c:1227:14
    #6 0x55afe2df74c7 in start_server /home/sam/git/rsync/main.c:1261:3
    #7 0x55afe2df6c34 in child_main /home/sam/git/rsync/main.c:1234:2
    #8 0x55afe2e606fd in local_child /home/sam/git/rsync/pipe.c:166:3
    #9 0x55afe2dfc438 in do_cmd /home/sam/git/rsync/main.c:646:9
    #10 0x55afe2dfc438 in start_client /home/sam/git/rsync/main.c:1577:8
    #11 0x55afe2dfa954 in main /home/sam/git/rsync/main.c:1848:8
    #12 0x7fa33c8ed64f  (/usr/lib64/libc.so.6+0x2364f)
    #13 0x7fa33c8ed708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708)
    #14 0x55afe2d7e1f4 in _start (/home/sam/git/rsync/rsync+0xd91f4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lib/pool_alloc.c:103:9 in
rsync: connection unexpectedly closed (188 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7-17-gb0a8dc24]
/home/sam/git/rsync/rsync  returned 12
----- symlink-ignore log ends
FAIL    symlink-ignore
PASS    trimslash
PASS    unsafe-byname
----- unsafe-links log follows
Testing for symlinks using 'test -h'
rsync with relative path and just -a
sending incremental file list
created directory to
delta-transmission disabled for local transfer or --whole-file
./
files/
files/file1
files/file2
links/
links/file1 -> ../files/file1
links/file2 -> ../files/file2
links/unsafefile -> ../../unsafe/unsafefile
lib/pool_alloc.c:103:9: runtime error: addition of unsigned offset to 0x7fabc60cd030 overflowed to 0x7fabc60cd010
    #0 0x55aaedab2c3a in pool_destroy /home/sam/git/rsync/lib/pool_alloc.c:103:9
    #1 0x55aaed9f2acf in flist_free /home/sam/git/rsync/flist.c:2956:3
    #2 0x55aaed9fc1fd in check_for_finished_files /home/sam/git/rsync/generator.c:2218:3
    #3 0x55aaeda03b43 in generate_files /home/sam/git/rsync/generator.c:2356:3
    #4 0x55aaeda2bd16 in do_recv /home/sam/git/rsync/main.c:1114:2
    #5 0x55aaeda294c7 in do_server_recv /home/sam/git/rsync/main.c:1227:14
    #6 0x55aaeda294c7 in start_server /home/sam/git/rsync/main.c:1261:3
    #7 0x55aaeda28c34 in child_main /home/sam/git/rsync/main.c:1234:2
    #8 0x55aaeda926fd in local_child /home/sam/git/rsync/pipe.c:166:3
    #9 0x55aaeda2e438 in do_cmd /home/sam/git/rsync/main.c:646:9
    #10 0x55aaeda2e438 in start_client /home/sam/git/rsync/main.c:1577:8
    #11 0x55aaeda2c954 in main /home/sam/git/rsync/main.c:1848:8
    #12 0x7fabd3abd64f  (/usr/lib64/libc.so.6+0x2364f)
    #13 0x7fabd3abd708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708)
    #14 0x55aaed9b01f4 in _start (/home/sam/git/rsync/rsync+0xd91f4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lib/pool_alloc.c:103:9 in
rsync: connection unexpectedly closed (157 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7-17-gb0a8dc24]
----- unsafe-links log ends
FAIL    unsafe-links
PASS    wildmatch
----- xattrs-hlink log follows
Testing for symlinks using 'test -h'
        makepath /home/sam/git/rsync/testtmp/xattrs-hlink/lnk
        makepath /home/sam/git/rsync/testtmp/xattrs-hlink/from/foo/bar
        makepath /home/sam/git/rsync/testtmp/xattrs-hlink/chk/foo
Running: "/home/sam/git/rsync/rsync  -avX -f-x_system.* -f-x_security.* -H --super . '/home/sam/git/rsync/testtmp/xattrs-hlink/chk/'"
sending incremental file list
xattrs.c:298:11: runtime error: applying non-zero offset 18446744073709551576 to null pointer
    #0 0x555e5108f050 in rsync_xal_get /home/sam/git/rsync/xattrs.c:298:11
    #1 0x555e5108f050 in get_xattr /home/sam/git/rsync/xattrs.c:329:6
    #2 0x555e50feb764 in send_file_name /home/sam/git/rsync/flist.c:1639:8
    #3 0x555e50fe9c3a in send_file_list /home/sam/git/rsync/flist.c:2444:11
    #4 0x555e51030a7e in client_run /home/sam/git/rsync/main.c:1317:11
    #5 0x555e510354cc in start_client /home/sam/git/rsync/main.c:1588:8
    #6 0x555e51033954 in main /home/sam/git/rsync/main.c:1848:8
    #7 0x7fc15467e64f  (/usr/lib64/libc.so.6+0x2364f)
    #8 0x7fc15467e708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708)
    #9 0x555e50fb71f4 in _start (/home/sam/git/rsync/rsync+0xd91f4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior xattrs.c:298:11 in
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [Receiver=3.2.7-17-gb0a8dc24]
----- xattrs-hlink log ends
FAIL    xattrs-hlink
----- xattrs log follows
Testing for symlinks using 'test -h'
        makepath /home/sam/git/rsync/testtmp/xattrs/lnk
        makepath /home/sam/git/rsync/testtmp/xattrs/from/foo/bar
        makepath /home/sam/git/rsync/testtmp/xattrs/chk/foo
Running: "/home/sam/git/rsync/rsync  -avX -f-x_system.* -f-x_security.*  --super . '/home/sam/git/rsync/testtmp/xattrs/chk/'"
sending incremental file list
xattrs.c:298:11: runtime error: applying non-zero offset 18446744073709551576 to null pointer
    #0 0x56439e2e0050 in rsync_xal_get /home/sam/git/rsync/xattrs.c:298:11
    #1 0x56439e2e0050 in get_xattr /home/sam/git/rsync/xattrs.c:329:6
    #2 0x56439e23c764 in send_file_name /home/sam/git/rsync/flist.c:1639:8
    #3 0x56439e23ac3a in send_file_list /home/sam/git/rsync/flist.c:2444:11
    #4 0x56439e281a7e in client_run /home/sam/git/rsync/main.c:1317:11
    #5 0x56439e2864cc in start_client /home/sam/git/rsync/main.c:1588:8
    #6 0x56439e284954 in main /home/sam/git/rsync/main.c:1848:8
    #7 0x7fcbf12cb64f  (/usr/lib64/libc.so.6+0x2364f)
    #8 0x7fcbf12cb708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708)
    #9 0x56439e2081f4 in _start (/home/sam/git/rsync/rsync+0xd91f4)
[...]
thesamesam commented 1 year ago

I get similar but different failures with GCC (including some unaligned accesses not currently guarded by CAREFUL_ALIGNMENT).

Full log: rsync-tests.log.

Snippet:

[...]
delta-transmission disabled for local transfer or --whole-file
.filt is uptodate
log.c:858:13: runtime error: member access within misaligned address 0x56205fbb4374 for type 'struct file_struct', which requires 8 byte alignment
0x56205fbb4374: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^
    #0 0x56205ec62a0d in log_delete /home/sam/git/rsync/log.c:858
    #1 0x56205ec647ea in delete_item /home/sam/git/rsync/delete.c:180
    #2 0x56205ec228bf in delete_in_dir /home/sam/git/rsync/generator.c:342
    #3 0x56205ec30adc in generate_files /home/sam/git/rsync/generator.c:2303
    #4 0x56205ec5512c in do_recv /home/sam/git/rsync/main.c:1114
    #5 0x56205ec55adb in do_server_recv /home/sam/git/rsync/main.c:1227
    #6 0x56205ec55adb in start_server /home/sam/git/rsync/main.c:1261
    #7 0x56205ec55f0a in child_main /home/sam/git/rsync/main.c:1234
    #8 0x56205ecba448 in local_child /home/sam/git/rsync/pipe.c:166
    #9 0x56205ebfe61f in do_cmd /home/sam/git/rsync/main.c:646
    #10 0x56205ebfe61f in start_client /home/sam/git/rsync/main.c:1577
    #11 0x56205ebfe61f in main /home/sam/git/rsync/main.c:1848
    #12 0x7fd2026f264f  (/usr/lib64/libc.so.6+0x2364f)
    #13 0x7fd2026f2708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708)
    #14 0x56205ec012e4 in _start (/home/sam/git/rsync/rsync+0xc02e4)

rsync: connection unexpectedly closed (99 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7-17-gd520c805]
----- exclude log ends
FAIL    exclude
PASS    executability
PASS    files-from
----- fuzzy log follows
Testing for symlinks using 'test -h'
Running: "/home/sam/git/rsync/rsync  -avvi --no-whole-file --fuzzy --delete-delay     '/home/sam/git/rsync/testtmp/fuzzy/from/' '/home/sam/git/rsync/testtmp/fuzzy/to/'"
sending incremental file list
delta-transmission enabled
.d          ./
>f+++++++++ rsync.c
total: matches=35  hash_hits=35  false_alarms=0 data=0
log.c:858:13: runtime error: member access within misaligned address 0x56394f3f0f14 for type 'struct file_struct', which requires 8 byte alignment
0x56394f3f0f14: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^
    #0 0x56394db2ba0d in log_delete /home/sam/git/rsync/log.c:858
    #1 0x56394db2d7ea in delete_item /home/sam/git/rsync/delete.c:180
    #2 0x56394dafa42a in do_delayed_deletions /home/sam/git/rsync/generator.c:262
    #3 0x56394dafa42a in generate_files /home/sam/git/rsync/generator.c:2405
    #4 0x56394db1e12c in do_recv /home/sam/git/rsync/main.c:1114
    #5 0x56394db1eadb in do_server_recv /home/sam/git/rsync/main.c:1227
    #6 0x56394db1eadb in start_server /home/sam/git/rsync/main.c:1261
    #7 0x56394db1ef0a in child_main /home/sam/git/rsync/main.c:1234
    #8 0x56394db83448 in local_child /home/sam/git/rsync/pipe.c:166
    #9 0x56394dac761f in do_cmd /home/sam/git/rsync/main.c:646
    #10 0x56394dac761f in start_client /home/sam/git/rsync/main.c:1577
    #11 0x56394dac761f in main /home/sam/git/rsync/main.c:1848
    #12 0x7fc09add464f  (/usr/lib64/libc.so.6+0x2364f)
    #13 0x7fc09add4708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708)
    #14 0x56394daca2e4 in _start (/home/sam/git/rsync/rsync+0xc02e4)

rsync: connection unexpectedly closed (288 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7-17-gd520c805]
----- fuzzy log ends
FAIL    fuzzy
----- hands log follows
Testing for symlinks using 'test -h'
Test basic operation: Running: "/home/sam/git/rsync/rsync  -av "/home/sam/git/rsync/testtmp/hands/from/" "/home/sam/git/rsync/testtmp/hands/to""
sending incremental file list
empty
filelist
nolf
nolf-symlink -> nolf
text
dir/
dir/text
dir/subdir/
dir/subdir/foobar.baz
dir/subdir/subsubdir/
dir/subdir/subsubdir/etc-ltr-list
dir/subdir/subsubdir2/
dir/subdir/subsubdir2/bin-lt-list
emptydir/

sent 2,101,811 bytes  received 199 bytes  4,204,020.00 bytes/sec
total size is 2,100,563  speedup is 1.00
-------------
check how the directory listings compare with diff:

-------------
check how the files compare with diff:

-------------
        done.
Test hard links: Running: "/home/sam/git/rsync/rsync  -avH --bwlimit=0 --debug=all0,deltasum0 "/home/sam/git/rsync/testtmp/hands/from/" "/home/sam/git/rsync/testtmp/hands/to""
sending incremental file list
dir/filelist => filelist

sent 431 bytes  received 29 bytes  920.00 bytes/sec
total size is 2,185,049  speedup is 4,750.11
-------------
check how the directory listings compare with diff:

-------------
check how the files compare with diff:

-------------
        done.
Test one file: Running: "/home/sam/git/rsync/rsync  -avH --debug=all0,deltasum0 "/home/sam/git/rsync/testtmp/hands/from/" "/home/sam/git/rsync/testtmp/hands/to""
sending incremental file list
text

sent 1,001,881 bytes  received 40 bytes  2,003,842.00 bytes/sec
total size is 2,185,049  speedup is 2.18
-------------
check how the directory listings compare with diff:

-------------
check how the files compare with diff:

-------------
        done.
Test extra data: Running: "/home/sam/git/rsync/rsync  -avH --debug=all0,deltasum0 --no-whole-file "/home/sam/git/rsync/testtmp/hands/from/" "/home/sam/git/rsync/testtmp/hands/to""
sending incremental file list
text

sent 4,649 bytes  received 6,052 bytes  21,402.00 bytes/sec
total size is 2,185,049  speedup is 204.19
-------------
check how the directory listings compare with diff:

-------------
check how the files compare with diff:

-------------
        done.
Test  --delete: Running: "/home/sam/git/rsync/rsync  --delete -avH --debug=all0,deltasum0 "/home/sam/git/rsync/testtmp/hands/from/" "/home/sam/git/rsync/testtmp/hands/to""
sending incremental file list
log.c:858:13: runtime error: member access within misaligned address 0x55af535c67d4 for type 'struct file_struct', which requires 8 byte alignment
0x55af535c67d4: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^
    #0 0x55af5177ca0d in log_delete /home/sam/git/rsync/log.c:858
    #1 0x55af5177e7ea in delete_item /home/sam/git/rsync/delete.c:180
    #2 0x55af5173c8bf in delete_in_dir /home/sam/git/rsync/generator.c:342
    #3 0x55af5174aadc in generate_files /home/sam/git/rsync/generator.c:2303
    #4 0x55af5176f12c in do_recv /home/sam/git/rsync/main.c:1114
    #5 0x55af5176fadb in do_server_recv /home/sam/git/rsync/main.c:1227
    #6 0x55af5176fadb in start_server /home/sam/git/rsync/main.c:1261
    #7 0x55af5176ff0a in child_main /home/sam/git/rsync/main.c:1234
    #8 0x55af517d4448 in local_child /home/sam/git/rsync/pipe.c:166
    #9 0x55af5171861f in do_cmd /home/sam/git/rsync/main.c:646
    #10 0x55af5171861f in start_client /home/sam/git/rsync/main.c:1577
    #11 0x55af5171861f in main /home/sam/git/rsync/main.c:1848
    #12 0x7fba5f25d64f  (/usr/lib64/libc.so.6+0x2364f)
    #13 0x7fba5f25d708 in __libc_start_main (/usr/lib64/libc.so.6+0x23708)
    #14 0x55af5171b2e4 in _start (/home/sam/git/rsync/rsync+0xc02e4)
[...]