fuzzing: Improve robustness and documentation of the ldd-base library copy
authorAndrew Bartlett <abartlet@samba.org>
Wed, 21 Oct 2020 23:05:29 +0000 (12:05 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 22 Oct 2020 12:47:37 +0000 (12:47 +0000)
This tries to make progress towards understanding why we sometime see errors like
Step #6: Error occured while running fuzz_reg_parse:
Step #6: /workspace/out/coverage/fuzz_reg_parse: error while loading shared libraries: libavahi-common.so.3: cannot open shared object file: No such file or directory

in the previously failing coverage builds.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/fuzzing/oss-fuzz/build_samba.sh

index 5980f88ad02dbab85a8d4bee01da67944bcec437..c9a5162f8012d2e10c2f9399d8e4f27076416984 100755 (executable)
@@ -94,12 +94,25 @@ mkdir -p $OUT/lib
 
 for x in bin/fuzz_*
 do
+    # Copy any system libraries needed by this fuzzer to $OUT/lib.
+
+    # We run ldd on $x, the fuzz_binary in bin/ which has not yet had
+    # the RUNPATH altered.  This is clearer for debugging in local
+    # development builds as $OUT is not cleaned between runs.
+    #
+    # Otherwise trying to re-run this can see cp can fail with:
+    # cp: '/out/lib/libgcc_s.so.1' and '/out/lib/libgcc_s.so.1' are the same file
+    # which is really confusing!
+
+    # The cut for ( and ' ' removes the special case references to:
+    #  linux-vdso.so.1 =>  (0x00007ffe8f2b2000)
+    #   /lib64/ld-linux-x86-64.so.2 (0x00007fc63ea6f000)
+
+    ldd $x | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d  ' ' | xargs -i cp \{\} $OUT/lib/
+
     cp $x $OUT/
     bin=`basename $x`
 
-    # Copy any system libraries needed by this fuzzer to $OUT/lib
-    ldd $OUT/$bin | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d  ' ' | xargs -i cp \{\} $OUT/lib/
-
     # Change any RPATH to RUNPATH.
     #
     # We use ld.bfd for the coverage builds, rather than the faster ld.gold.