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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4463 invoked from network); 12 Mar 2021 21:15:08 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 12 Mar 2021 21:15:08 -0000 Received: (qmail 26313 invoked by uid 550); 12 Mar 2021 21:15:04 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26292 invoked from network); 12 Mar 2021 21:15:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=veMars1A3T6Rh6c15ipT2QN3kN0t6cYPV+oQeksm1sQ=; b=fYi4LzajUYAtosEYdR0AQxEhiXfrkQvpzMMuPJqZAXt2oZwWBC/MDZVAvsv0UtgA/F npfQCuL6vHxXjGFVThpKQe8wk1S4m0r5EfoIOiNof3cMQidhSvc4S+3D4eCftuTBC7yj VVYFoCyMYf7oOEQ2DGCZxLyvuhpjYoAfnUBQ7afi9AFSwr1u/vyBP63oaXMDOQbyh8u5 WZz5f6Qaa0EoALb3Dn1bYHT9dEyWxkKzIzmRr5G/kJjQ87sTdbtqv6fwTUNG+ZdlcwGm uXV1qMO/E9w6dOqaUyeJHmH8UhwlTMZ3dZvL/Iouc/uJzfvZJ0cge/onpMjwxQ8IsCgb wG4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=veMars1A3T6Rh6c15ipT2QN3kN0t6cYPV+oQeksm1sQ=; b=Rqs6SunFBsXWHnqC+kxIcPLocYp6G4VYGPk3j1HLM3kT8ORxJIoLzAm3ndsy54NOIJ Qbs0OTx364gp20KefUZZcr1hjCVW1iw46sSMsw9s08i6s6GTvWjONDGCRU8cjFmUk2MO s4+uRDDTPgXHvdM6CKiGroy9mYI2m/4I9mBrjUrkRJ9uFGHUOidvsVXsYLheTQFBT43L DroqjEJtazNFfUCtkVYI3uc5loS6m7EUdV3X8v6R+SyYVBqbDVre+YQfmtZmVN5qWdZo Jl0HhJNEVMkQ6SRztrPSPoVx+7ZHZzJ0KIOLnIoEpFcXKkvPmB863MuKw1pwKlAl3GIu A07g== X-Gm-Message-State: AOAM5324o3YOyPH8EExE2PqdD7uiWpgD1xBgr+JougnuLioKj7ae0wrf H3Peuxwm7yA6sKRmss8Af86+CNcaisQ= X-Google-Smtp-Source: ABdhPJytlzOj2qpXlWfrKjPUvRsF/K8VYdX3T0C7XMfBWR5J6VWnHKAgoyjrkQ7V2Cvl7pjquw46OA== X-Received: by 2002:a37:2e46:: with SMTP id u67mr14933233qkh.488.1615583691557; Fri, 12 Mar 2021 13:14:51 -0800 (PST) To: Rich Felker Cc: fweimer@redhat.com, musl@lists.openwall.com References: <62be4b85-4a42-413e-a83f-866eab4d601a@gmail.com> <20210203192145.GW23432@brightrain.aerifal.cx> <20210203210149.GX23432@brightrain.aerifal.cx> <20210203225518.GY23432@brightrain.aerifal.cx> <20210215165622.GF11590@brightrain.aerifal.cx> <2e2e3693-b16a-d158-9617-99978a2b287f@gmail.com> <20210217201156.GK11590@brightrain.aerifal.cx> <20210217210748.GL11590@brightrain.aerifal.cx> From: Dominic Chen Message-ID: <60a94ab1-4682-fd04-37ce-92d61207988d@gmail.com> Date: Fri, 12 Mar 2021 16:14:51 -0500 MIME-Version: 1.0 In-Reply-To: <20210217210748.GL11590@brightrain.aerifal.cx> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [musl] Incorrect thread TID caching On 2/17/2021 4:07 PM, Rich Felker wrote: >> Whether it's inlined isn't really a big deal; this is not a hot path. >> It's more just a matter of how it needs to be split up at the source >> level, and it seems to be messy whichever way we choose. >> >> Trying to avoid calling __clone doesn't seem like such a good idea, >> since the child has to run on a new stack -- if we did avoid it we'd >> need a new way to switch stacks. The generic __unmapself has a hack >> to do this already that we could reuse without needing new >> arch-specific glue though. >> >> I'll keep trying things and see if I come up with something not too >> unreasonable. >> >> Attached is a draft of how clone() *could* work without refactoring >> the pre/post logic from _Fork to use __clone. I don't particularly >> like it, and CRTJMP abuse like this (which __unmapself also does, as >> noted above) is not valid for FDPIC archs (it actually expects a code >> address not a function pointer). I'll try a version the other way and >> see how it looks. Sorry for the delay. I did end up needing robust mutex functionality, and ended up using a variant of your patch to fix-up. There were two issues that I noticed: 1. Prior to CRTJMP, the 'arg' argument needs to be moved into the first argument register for the local calling convention. I spent a little time trying to get an architecture-neutral version working using a wrapper function, but gave up and used some inline assembly to populate %rdi on x86_64. 2. If a thread exits without unlocking a robust mutex, the program will subsequently SIGSEGV since the thread's memory region has been unmapped, but a pointer to the robust mutex remains on the internal linked list. Not sure where the fault lies here, but just thought I'd mention it. Thanks, Dominic