From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10935 invoked from network); 14 Sep 2022 21:44:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Sep 2022 21:44:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1663191851; b=qDtaDnNkYVPjyFZvm9tGNMYhEYmTB911/tCPjTsozOl8nND2uJKxPTu4SZM3CEbmYiXiYyDQ18 ZZvg2mdNd2od/A3El+PEhkUfmGLD1owW3N8Rwjxx1OUoKOrSnL0Z+3eh7fBFGhhX4FpX/YQDsH d+BVduGukeklrTT2ELy/EyZk5wOKhvH129XRI5ZVzJgF0q2PyMxokdgFIMrMa/IXQjF3zawF/J WblwFGtgiCkZcG+cZRpDztshrGWhb84pjpY3LSjqWWhPTmnNUfoqGZwxaNroTjduCsiHmftI6L tdI+SCb11Xn6v1k37VqiBorlafu0CFvAZ5lZyh6l/dgu2w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1663191851; bh=L67rXiUlSAe4XSbgk8BcXIUr/nqGhNpyzzH3yAKVCNw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=SMIpIAmcz1g+r+OQ9Txwag4MVmg1mwXqXAbiAUrS+H7k6KIMcaSWetsEDugSrs2J/RTigt6wc4 b8B5pdNsSxvOVoOiFDAPNXHtWKWtn1yVuPPZk9e9vuHndqwXlwpmyxJS44V3I8lizWsyGMSvK5 GvsBxYIAb6UXZCbjgp+Y7vm9xgpVYUugQW5e0ryS5+Ike7xHIBVkWJC7lrT8cV8kvjCh050zM+ vma481SU9EyU2ntISGOBFLji3WRp2M6equiKkGh/1M75bph5WSAHcQe0XaNRXqU1aatXSncPqQ NIHoA+RvugbxFJwlFySxg7vu7Ae7rUemdonvrCIbJeS5gA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=lqaqDH/wgN7NNnNBrZtE23J+JF8pru5XAWbMCw6ArX4=; b=mS36QRgIaraCvSjdQ6NCNI2YzU 4rHR0PuQTSC9vJGAiz/0yi43H3cYcXoB0OQLpq7DrSzKx9+tdkYwPsCKeT+vxdEwq04NETA3wyYHw VG6HzSHk0Sn8I2llj5Q8qOH+1IhSyK+TaZxIrABoXa2ty2xzsUN4B0/+4d2Lh+VetR9lJ6Y2QxSEc RjEEzvy0U/6xUgTC6Av9S4jltpPB5j0GP0qspV7ncRJkhm3x3HA+lzHsMPZTh8F4XAAyESb5Zxtme GKFEMk86cZ4EpesQ+G/Q6YGLwgE+nMQXi4jZwgnT3EpkPPbouaBE2eACicIQjZDIM+16xcBNV+Ecp Vz/zht2Q==; Received: from authenticated user by zero.zsh.org with local id 1oYaB0-0004NA-JP; Wed, 14 Sep 2022 21:44:10 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f42.google.com ([209.85.218.42]:46939) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oYaAi-00042O-IG; Wed, 14 Sep 2022 21:43:53 +0000 Received: by mail-ej1-f42.google.com with SMTP id bj12so37725233ejb.13 for ; Wed, 14 Sep 2022 14:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=lqaqDH/wgN7NNnNBrZtE23J+JF8pru5XAWbMCw6ArX4=; b=hFUP60N0GPs82qcipW1DsxE9WX4V/kI4rRgwKKleSlUSCdAb9fym25Zi8G4KieGzJ0 XBwVGUP2rcM2tBabh6FbjoMZvWiVLIWHlJqLHQO0/HCB9bnpHgAMQfNekUNpd8UNyA9T 6APcI4sTp35SDj15RekI2oJxS2HSKkBxqifmiaMEDhbWs6FluQA6ehG0uzep95Rf7bqk x+atmW4cD80FyuXKr2fAexPOCBxfY+oiLg2PyG9lsTeRU20avxSdwrNLUeoJZvnsSeG/ lWA55JVn4bS3WYGWmLPoE/VYaKBonsZ80AALOx4l00E+vndFxpmgb/9j6iw7CYidgnYk 2cUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=lqaqDH/wgN7NNnNBrZtE23J+JF8pru5XAWbMCw6ArX4=; b=NJ8mprP2spMiT6ovhALsg94f7Dlb3/+aADqbQlpr6SeDPSnmF0xvOSVKXcltfBfYE+ bvTC/FMUaR9E22z+cRHTM5FCM/Dm34Mz3WFzeLjHDbntoC8mKM2I7g6DG+cwJ+XjOCz2 5085w7Ayr4N02KWD7Kkxo3cIQ26Y0M+39jrvAUOJhhIoTwcPVqvpmZag9LM8TSfvshsP XHinEQpTwEtGAix+BMiEFmkVsCEGFs9Fphow/fMg9liBpPwbNa1pJgRCR7IdR2jCBb3M adofJT17G1Oipz1Ercuv0ZTIA1kUfkGGMIdNewyBBRFt729wDs2canBAZLnjHlCl1mNm QNlQ== X-Gm-Message-State: ACgBeo37r3OsOLjFX5DIu4QCth3NBh3eoJZF+JigCp/mEJloDpUoZ5WW 7JrJ40D7jkUaZ4978BJ9sA1ZKVDEyVZx3xJtsJ78ggB/dMNzvQ== X-Google-Smtp-Source: AA6agR5vZDEGtfYS/TfYE1yHzeAugPxDjSd2FMBugTOv4sbPvPoLDtQd66lif0sTgPdFk2shCkc/lS3AjYcb0+XjILw= X-Received: by 2002:a17:906:9bd3:b0:76f:8cce:7a61 with SMTP id de19-20020a1709069bd300b0076f8cce7a61mr26968943ejc.345.1663191831907; Wed, 14 Sep 2022 14:43:51 -0700 (PDT) MIME-Version: 1.0 References: <8F410818-257D-470A-B620-2F776E960ABC@kba.biglobe.ne.jp> In-Reply-To: <8F410818-257D-470A-B620-2F776E960ABC@kba.biglobe.ne.jp> From: Bart Schaefer Date: Wed, 14 Sep 2022 14:43:40 -0700 Message-ID: Subject: Re: ZSH crashed when reading bytes from a large binary To: Jun T Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 50633 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Mon, Sep 12, 2022 at 12:37 AM Jun T wrote= : > > > 2022/09/11 23:43, Liu, Song wrote: > > > > The problem is that, when ZSH failed to reallocate memory, ZSH didn=E2= =80=99t check the return value of `realloc` function and handle the error. = This will make ZSH crash. > > There are many other places where the return value of realloc() is not ch= ecked. > 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. > > } else { > > free(buf); > > return EXIT_FAILURE; > > } 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. (Aside, we use EXIT_FAILURE exactly nowhere, so if we do not exit, this should just be "return 1" as if end-of-file was encountered per docs.) In most cases we've assumed that once the shell is out of memory, there's no way back, so how it dies is not that interesting.