Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ZSH crashed when reading bytes from a large binary



> 2022/09/15 6:43, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 
> On Mon, Sep 12, 2022 at 12:37 AM Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>> 
>> Can we simply replace them by zrealloc()?
> 
> Replacing them with zrealloc() will still result in immediate exit of
> the shell, just with a different error message and no stack trace.

On Linux zsh coredumps without any error message if realloc() is used.
But getting core would make debug easier...


> The specific question here is whether having the "read" builtin return
> failure at this point will allow the shell to recover from the
> out-of-memory state, or whether it's just delaying the inevitable
> death.

Consider a script something like:

if read x < $file; then
    # do something
else
    rm $file     # it's empty and we can remove it
fi

Yes, this script is wrong since read returns 1 even if $file is not empty
(if there is no \n). But I fear there may be some (only a few?) users
using scripts like this.



Messages sorted by: Reverse Date, Date, Thread, Author