Closed bczhc closed 1 year ago
Hi! The first error is a regression introduced in #55 that is now fixed on master. To quote about the confusing error message:
In some cases, this message will occur even when no ioctl has been issued by the program. This is due to the way the isatty() library routine works. The error code errno is only set when a system call fails. One of the first system calls made by the C standard I/O library is in an isatty() call used to determine if the program is being run interactively by a human (in which case isatty() will succeed and the library will write its output a line at a time so the user sees a regular flow of text) or as part of a pipeline (in which case it writes a block at a time for efficiency). If a library routine fails for some reason unrelated to a system call (for example, because a user name wasn't found in the password file) and a naïve programmer blindly calls the normal error reporting routine perror() on every failure, the leftover ENOTTY will result in an utterly inappropriate "Not a typewriter" (or "Not a teletype", or "Inappropriate ioctl for device") being delivered to the user. For many years the UNIX mail program
sendmail
contained this bug: when mail was delivered from another system, the mail program was being run non-interactively. If the destination address was local, but referred to a user name not found in the local password file, the message sent back to the originator of the email was the announcement that the person they were attempting to communicate with was not a typewriter.
As for the memory errors, if you recompile with -g3
you discover that they are caused by libsais
:
==54331== Invalid read of size 4
==54331== at 0x10B86A: libsais_bwt_copy_8u (libsais.h:4037)
==54331== by 0x115621: libsais_bwt (libsais.h:4117)
==54331== by 0x115621: bz3_encode_block (libbz3.c:574)
==54331== by 0x117696: process.constprop.0 (main.c:224)
==54331== by 0x10956D: main (main.c:695)
==54331== Address 0x524c0b4 is 4,194,420 bytes inside a block of size 4,198,304 in arena "client"
==54331==
==54331== Invalid read of size 4
==54331== at 0x10B87C: libsais_bwt_copy_8u (libsais.h:4037)
==54331== by 0x115621: libsais_bwt (libsais.h:4117)
==54331== by 0x115621: bz3_encode_block (libbz3.c:574)
==54331== by 0x117696: process.constprop.0 (main.c:224)
==54331== by 0x10956D: main (main.c:695)
==54331== Address 0x524c0b8 is 4,194,424 bytes inside a block of size 4,198,304 in arena "client"
==54331==
==54331== Invalid read of size 4
==54331== at 0x10B88E: libsais_bwt_copy_8u (libsais.h:4037)
==54331== by 0x115621: libsais_bwt (libsais.h:4117)
==54331== by 0x115621: bz3_encode_block (libbz3.c:574)
==54331== by 0x117696: process.constprop.0 (main.c:224)
==54331== by 0x10956D: main (main.c:695)
There is nothing I can do about this at present, because the maintainer refuses to fix these memory errors even though I have an evidence that invalid input will lead to a segfault (see #59).
If you feel like trying to make libsais memory safe, your effort will be greatly appreciated.
Future problems related to libsais are to be discussed in #59.
I see... Thanks for the info!
When the block size is 1MiB, this happens:
Exit status indicator:
✔ PIPE|0|0|1|0
, meaningbzip3 -d
exits with status code 1, with theWrite error: Inappropriate ioctl for device
error.But after changing the block size to a higher one like 2MiB, it doesn't happen.
Also, when using
valgrind
on bzip3 with the 1M (2M it's okay) block size, it reports so many invalid reads and writes. Are these memory errors a serious problem?