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=0.2 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 11672 invoked from network); 22 Jan 2023 00:38:36 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 22 Jan 2023 00:38:36 -0000 Received: from mail-lf1-f42.google.com ([209.85.167.42]) by 9front; Sat Jan 21 19:37:16 -0500 2023 Received: by mail-lf1-f42.google.com with SMTP id cf42so13261863lfb.1 for <9front@9front.org>; Sat, 21 Jan 2023 16:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FsGPjtlTJN8/MBzHK8a3g02UYWedEMlc4rFj9afgtkQ=; b=Ud0IRBXgCUyd/djVabAcvnGGubMMJP9HqIv0Tx/7WDUVU0T0ZfxXCwooSd8GZWiD9f 0/CbJV05j/XRSKlv8Ovqidm1wmtDWiNHecGdCRWCOpljxoqPxsefLywtCyeLPYRf+B9X ZPU3uipzeq7aowEWoaQqMrQvw/U9OQRA1JGcVrl4OhTsC3VjEgwCfc6y1iR//ymcEOtM d53UVmU7eDEisWw1rE8RuGA9Xk3jT75BqcFMHdJXPZnS8FWXuxV8RBlfBUb0i4oL6ErA 9qNm4gdhRRbvGBrHb5PGd5WZ/7p40w5pkUTaPKtHzHBHEUeHFYAEQt+n4C++V44OLpr0 iIFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FsGPjtlTJN8/MBzHK8a3g02UYWedEMlc4rFj9afgtkQ=; b=0+Yt2N7GedJ5yBekblDu0kLvryrlfoAZAduXaV9445WL4zLCGqTieZ9M3Hi0BomROW oXm2CyvLioI/kB4K/SM/LG1K3YZcxuE6ZhZdJci4reM0rudC6MYVLouzKqJNDbjrZgCy 18AYkhpvjxnzV8NeDd4OChFmXMeks52i7II2MJOeKcqyKvXuGvI7zTRXtrHosMjij8en WNub5YPFzcuJKUXx1cIfnlY3jH5e2UPpqgyMuRss36N/QaVlHkUCYzDpDerkLRps9pgS M7qMKnVGweBkEkh1KAUbn43J8fIe790eCb0SZSXObtm1s/VdJXLk2o7vIZbpm92LWDtT 57ug== X-Gm-Message-State: AFqh2kpnOgQv775aHHv0NeRlFSYsG4gmGtp3iDp4vHydxetLScWoWUr8 v2810C7nH/U14pzIWrSv0zTmA2dtXBXXKb3iOM79ACQP X-Google-Smtp-Source: AMrXdXtSCD1PxFCQgdQ4Ca3Kbnw/yZgv+a83gEBAe4OHzseDb1Z78gqvisqdXIdwEIHvE7SD4i96NwMIABxkKbXgjlQ= X-Received: by 2002:a05:6512:e9e:b0:4cc:716d:e018 with SMTP id bi30-20020a0565120e9e00b004cc716de018mr1015735lfb.367.1674347830833; Sat, 21 Jan 2023 16:37:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Dan Cross Date: Sat, 21 Jan 2023 19:36:34 -0500 Message-ID: To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: advanced factory-scale API layer Subject: Re: [9front] lock: Fix some memory leaks Reply-To: 9front@9front.org Precedence: bulk On Sat, Jan 21, 2023 at 3:52 AM Steve Simon wrote: > sorry, but this patch looks very wrong. > > free after return does nothing. > calling waitfor twice allocates data twice. I've got no real context here, but a couple of brief observations: The `return` mentioned above is conditional on some pid having an expected value. The `free` added in this patch is for the non-return case where the conditional does not evaluate to true. I don't see how `waitfor` is called twice in this patch. Rather, it appears that a call to `waitfor(...)` was replaced with `free(waitfor(...))` > i would also consider what happens after the waitfor() call - i have not = looked at the source but i have a suspicion that lock exits, so there is no= point in freeing memory anyway. It does appear that `lock` exits here. - Dan C. > > On 21 Jan 2023, at 12:18 am, Josiah Frentsos wrote: > > > > =EF=BB=BFdiff bb36ba0617b5aa8263ea9b5ece8c1a5249fedc86 uncommitted > > --- a/sys/src/cmd/lock.c > > +++ b/sys/src/cmd/lock.c > > @@ -35,6 +35,7 @@ > > } > > if (w->pid =3D=3D pid) > > return w; > > + free(w); > > } > > } > > > > @@ -141,7 +142,8 @@ > > error("wait"); > > > > postnote(PNPROC, lckpid, "die"); > > - waitfor(lckpid); > > + free(waitfor(lckpid)); > > + > > if(w->msg[0]){ > > p =3D utfrune(w->msg, ':'); > > if(p && p[1])