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 4589 invoked from network); 12 Aug 2022 20:23:52 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Aug 2022 20:23:52 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1660335832; b=IYpI/+oT81o7XXfv+jvuLrMpEU/N8AhjAQcjW6doiTjT01tlkV2g6AXEroilk51OCR/8Wz92ns QFp9R0Ry6PhjuZNBBx2s/GlP/RCuQv5CHuq0kZfymmXnu9CjRgLZ3W7zAS6oZzM7H9fjjp+A6x VjSI9F2jzouNBu4tboqgxWsPN0rBXvDCbT53n2Gj2fhEsW3e8aCzjB81sVZwkRgI7QzQ30uQic ps1sLUEJWRnY3t45p+fXH9MZmzQNjUYMopUggNOUvS0rPleSNZ42BdfMJjwh5guu2xgBmV1ioD Rej6V2JoH3o6wZ4E4Whc4JlmpU8Do3T/HAJ2EzBCWe+m1Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f41.google.com) smtp.remote-ip=209.85.218.41; 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=1660335832; bh=CijaJP8Q9lwwTBN0QEV2oTwXSZnrRgiFcG1rV+2n7S0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=EqTafkCybgQPP6X9vlOvKfwaL/ilM5iSayRcD1qwAXnIlA0ee1joxrpj0lB7KTi8mvxqvDj3bN N43J1thQFV0TlqOhJzRCwYOF6BcTRS08yEkoy7l8bR+evtWDaL0EerBcBGKmLHBuNEiwU0zCxZ EUsO8PovvVv4nUWWgmpCmU9bQbyF1Ueoy1DkX7SEfCvwOHWtX/Qeia+GstZ0kNjb8aZeZUoEWs V4soUjV9ztP7KoqjoEM1bmdJMieM7ZasOCW9Qjar6gQYcCArZH5UOgkPpHDSsTNFZ7cAWQHIZW V5dxxaCQFUJL5qVraYbdn7XsOVbLLbdLRR0Pu4023sXtAw==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=SvmhWj4ifDQPncE4B07pXYQQinkh38ndWT0KqMA7LBw=; b=iBXDfa3SrOrZHRXAUkC+dtnIBa Ib4AQJDcBe139Holib5vYDYOBWl1PAg7sg3q7pWLwlPPNrYYLQXNfEVmeLZ+WNPlhSbXRKLVKHGn1 pdc/5XlHqRakk1lZoWi4JxjiLz/JtQXl7Q16fQ7IDQX0fBImMf+c+7OKLLeIz3znWDpSZmdRZzn8g 8iQbPORn1hhIYrf3PAT+AWFLfA/PXT2qnmeM44Kkwc7Keojq6vFmXx5wcHjIfI9ZcVvz4I7rWn1xP wGG6OnWTCsO1Uv3xjwwGXVKF6eijd8YwIZri0oDJ7MB0vOG64W8jIW9Tp2lOqVXf8LG2pC+bEqoAM kvXOXyMQ==; Received: from authenticated user by zero.zsh.org with local id 1oMbCB-000MVM-O8; Fri, 12 Aug 2022 20:23:51 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f41.google.com) smtp.remote-ip=209.85.218.41; 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-f41.google.com ([209.85.218.41]:41607) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oMb74-000M2n-AJ; Fri, 12 Aug 2022 20:18:34 +0000 Received: by mail-ej1-f41.google.com with SMTP id gk3so3779758ejb.8 for ; Fri, 12 Aug 2022 13:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=SvmhWj4ifDQPncE4B07pXYQQinkh38ndWT0KqMA7LBw=; b=Au/sue0TKCML5/XX6LSvnEG//8DBp3QHCwXV4CkML+oKYDfz1I2ML2aNQRQZYrQSZl X0pD+SARwWNxpFp0a711n4ejOhSRfbWCgfKQWVh60NNyxfJv0xW601D2QJqaZCDSjszJ EkE+OsFKCJAzGHLCQl3AaXNmhGFuMNWWJJjS18ev2v0rtEy0nGaunH47DJBDwdl9LYy1 RoETCcXayHG7x3FwOHlHhq6i48CtEwc6tZJaBtfgOwnpbxC/iSLKljbS3ahH3DgdJDDR aNx+qMMg2bfXut4b8dPf46CucaQPGadAH0DfgfJ5+iyWfEoLfHhQc6eNxfLkdhG//OUi iytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=SvmhWj4ifDQPncE4B07pXYQQinkh38ndWT0KqMA7LBw=; b=v9Iii7nCOjiLPTmnaclYJdXIBBXyDrTl4HnbRffjh+2a6emgoDrHS07Wk6SLA/qxVb TIbywRoEVmMTJWLXEPqhQ/mDTmEYhz2ZofA4HVveJ/Z2Je/JW87TGpDSHxSNvfQpTxPm LG+S1kVsF46KWXf0viTQC9SFajT9Pq4fCOtfQSTpXDUio8B6cKOF2M48dOUABL0k7odD CgkcYYXlRTqZjsyL4hp6qfCXraONHKj3Eq0/wf0TEozOM5favAH2UsZiGo6oiitG1WbH hBhaON9VOf5krr2VPaIjQZSkMM5AKG5zR68BRlpVviedYBqaE/KFDUL8WjTT4lMDFbGw rHig== X-Gm-Message-State: ACgBeo2S60c79zxDrPgEVuyQ70w+cmXzBMiuJbw6yP0Bep6hczOlWuEX psqzjJmxvxwBBe+SdOiQ2wru5GsQHNh258y0MxDhPi2SqmU4XQ== X-Google-Smtp-Source: AA6agR78TZKdAJI8dPA+UHCV6qA+SmCa3mCih9UVy3ZDIAub9fLj2xNrAp2GUlyRwxoojJoZSwPJJfaJL68ehUJ6O18= X-Received: by 2002:a17:907:9482:b0:730:6e79:7e75 with SMTP id dm2-20020a170907948200b007306e797e75mr3600174ejc.345.1660335513595; Fri, 12 Aug 2022 13:18:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Fri, 12 Aug 2022 13:18:22 -0700 Message-ID: Subject: Re: out of memory error after "edit-command-line" To: linuxtechguy@gmail.com Cc: devs Content-Type: text/plain; charset="UTF-8" X-Seq: 50472 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 Fri, Aug 12, 2022 at 8:41 AM Jim wrote: > > Tried to isolate what causes the 'out of memory' errors and found that if > I added quotes the error stopped. > CL=${(0A)"$(< /proc/$P/cmdline)"} # OK > CL=${(0A)$(< /proc/$P/cmdline)} # out of memory error I didn't reproduce the out-of-memory error with zsh-5.9-31, but I did reproduce an infinite loop in wordcount() because skipwsep() does not consider a metafied NUL byte to be whitespace. spacesplit() is entered with e.g. 'zsh\203 -f\203 ' and calls wordcount() on the first \203, which returns 2, then calls skipwsep() which returns without skipping anything because iwsep(' '^32) is false, and around we go again. I think the OOM is related because spacesplit() will allocate memory for each word that it believes it found, and the loop causes it to keep finding empty words forever. With sufficient RAM it just takes so long to use it all up that I give up waiting and kill the shell with gdb, which is how I found the loop case. However, I can't come up with a minimal test case to invoke the initial condition. It's not enough just to do e.g. ${(0A)$( But even so, should zsh ever fail with an 'out of memory' error? There's really no way for the shell to know that it is imminently going to run out of memory and no useful way to recover once it has done so. Except in cases of bugs (which this appears to be), OOM only results from a programming error on the part of the user. Back to the original problem ... it appears that findsep(&s, NULL, 0) considers '\203 ' to be a separator (because a null byte is in $IFS ?) but skipwsep() does not. Can anyone else see why this doesn't break in every case of splitting strings with embedded NUL ?