On Sun, Dec 25, 2022 at 09:21:34PM -0800, Eric Biggers wrote: > On Sun, Dec 25, 2022 at 08:46:00PM +0800, Zorro Lang wrote: > > > + # Reading the full file via mmap should fail. > > > bash -c "trap '' SIGBUS; $XFS_IO_PROG -r $fsv_file \ > > > -c 'mmap -r 0 $page_aligned_eof' \ > > > - -c 'mread 0 $file_len'" |& filter_sigbus > > > + -c 'mread 0 $file_len'" >/dev/null 2>$tmp.out > > > + if ! grep -q 'Bus error' $tmp.out; then > > > + echo "Didn't see SIGBUS when reading file via mmap" > > > > Hmm... will sigbus error really be output to stderr? From a testing, the > > generic/574 fails as: > > > > # ./check -s simpledev generic/574 > > SECTION -- simpledev > > FSTYP -- ext4 > > PLATFORM -- Linux/x86_64 xx-xxxxxx-xxx 6.1.0-rc3 #5 SMP PREEMPT_DYNAMIC Tue Nov 1 01:08:52 CST 2022 > > MKFS_OPTIONS -- -F /dev/sdb > > MOUNT_OPTIONS -- -o acl,user_xattr -o context=system_u:object_r:root_t:s0 /dev/sdb /mnt/scratch > > > > generic/574 - output mismatch (see /root/git/xfstests/results//simpledev/generic/574.out.bad) > > --- tests/generic/574.out 2022-12-25 20:02:41.609104749 +0800 > > +++ /root/git/xfstests/results//simpledev/generic/574.out.bad 2022-12-25 20:21:57.430719504 +0800 > > @@ -1,6 +1,32 @@ > > QA output created by 574 > > > > # Testing block_size=FSV_BLOCK_SIZE > > +/root/git/xfstests/tests/generic/574: line 69: 1949533 Bus error (core dumped) bash -c "trap '' SIGBUS; $XFS_IO_PROG -r $fsv_file -c 'mmap -r 0 $page_aligned_eof' -c 'mread 0 $file_len'" > /dev/null 2> $tmp.out > > +Didn't see SIGBUS when reading file via mmap > > This test passes for me both before and after this patch series. > > Both before and after, the way this is supposed to work is that in: > > bash -c "trap '' SIGBUS; command_that_exits_with_sigbus" > > ... bash should print "Bus error" to stderr due to > 'command_that_exits_with_sigbus'. That "Bus error" is then redirected. Before > it was redirected to a pipeline; after it is redirected to a file. > > I think what's happening is that the version of bash your system has is not > forking before exec'ing 'command_that_exits_with_sigbus'. As a result, "Bus > error" is printed by the *parent* bash process instead, skipping any redirection > in the shell script. > > Apparently skipping fork is a real thing in bash, and different versions of bash > have had subtly different conditions for enabling it. So this seems plausible. > > Adding an extra command after 'command_that_exits_with_sigbus' should fix this: > > bash -c "trap '' SIGBUS; command_that_exits_with_sigbus; true" Thanks for this explanation, I think you're right! I'm not sure if it's a bug of bash. If it's not a bug, I think we can do this change (add a true) to avoid that failure. If it's a bug, hmmm..., I think we'd better to avoid that failure too, due to we don't test for bash :-/ How about your resend this single patch (by version 2.1), to fix this problem. Other patches looks good to me, I'd like to merge this patchset this weekend. Thanks, Zorro > > The joy of working with a shell scripting system where everyone has different > versions of everything installed... > > - Eric >