The following seems like it should be a non-destructive reproducer case for the bug, based tightly on the original example, but it also doesn't let me reproduce the problem - the 'cleanup' trap definitely still triggers.
$ sudo bash -ec 'src="$1"; img="$2"; trgmp="$3";
mounts=""
cleanup() { for m in $mounts; do echo umount "$m"; done; }
trap cleanup EXIT
echo mount -o loop "$img" "$trgmp"
mounts="$trgmp"
echo unsquashfs -force -xattrs -dest "$trgmp" "$src"' "squashimg-to-image" foo bar baz
mount -o loop bar baz
unsquashfs -force -xattrs -dest baz foo
umount baz
$
The following seems like it should be a non-destructive reproducer case for the bug, based tightly on the original example, but it also doesn't let me reproduce the problem - the 'cleanup' trap definitely still triggers.
$ sudo bash -ec 'src="$1"; img="$2"; trgmp="$3"; to-image" foo bar baz
mounts=""
cleanup() { for m in $mounts; do echo umount "$m"; done; }
trap cleanup EXIT
echo mount -o loop "$img" "$trgmp"
mounts="$trgmp"
echo unsquashfs -force -xattrs -dest "$trgmp" "$src"' "squashimg-
mount -o loop bar baz
unsquashfs -force -xattrs -dest baz foo
umount baz
$