From nobody Tue Jan 14 17:55:15 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YXcGr69nDz5kDBt; Tue, 14 Jan 2025 17:55:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YXcGq70Y2z44LG; Tue, 14 Jan 2025 17:55:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736877316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Vjg7gx+3vIXAeYyJ4Ya0VqN62BQvUCz/XiEPkJ/Ngic=; b=hECWCzieg5M/1LcqvdikWeEH5tdoVMlC9F70hWKCjhuTbgQGnnBNxlP6Zy8huHf5oygmZm AVFR8T4Xn3/77SCvA/HrrAHThELzqli1UW2kwL3LsM26wb7OX1t+tXFZdh+zmVkPKlpd8m 0+NBTGW2cLKk0VDjkIyE8J4VaNZFUtHZSVBd6p9mzbtxro/6pGfYo7CHP8yPXKgeqJGU+G uz58bmg0Cd0GgSNgCAszD7mQbzCqDrhkaidJoCHClXwDCHg09glqUjVRVTnG3ktnXu48n5 GX2BVltasqp5VzmS8suBclXcatbjjz9RMOb+bfLJ1na58lSy2Mjn6rMxNR2vfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736877316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Vjg7gx+3vIXAeYyJ4Ya0VqN62BQvUCz/XiEPkJ/Ngic=; b=V4G+xbTktaYVw4Ts6znsEGybFdU1Sxj/d8iohSzQ5F3UoPx1JyNQokQ5LLMmdWKeYQB1f7 xQ9BO67WPWV1DQRN0ZuAdu0lp9MJASYymPnaKn4453icUQZusi40ARtOARmh86HucWVD6r rL5qDMpd0bJrJrR63TlUhup5nOhoJdPKGQR40yvzfWrbTVbNw4seBSuiCR3Di7zgSBb3pd tR0GCxecJpMfl0LRdvYWm362leljdFQX4WQieJcTBCZYRvlaKIDI79LR11jv80rVqHEv1P tA6L+XKGM0QKoQXwd0s+GuLGo76IX7XVU3EoFZKX40t9K3Xbc8lPOGHcxtTKBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736877316; a=rsa-sha256; cv=none; b=w6R8FyrvmFIXvQ+zN5QtYC96XoBg+wpJaO2CW0h68LAvHWrctY2yOIfcT2/Vr3AlNtUN9Z oHo/0M2DOjk+cyuMUqIkgsMyPY461Q+PllLUq+IdkALB2xhjQyu32L8JJ3MvHyioBMhSBe MJXSbX/FrKvMe2oWhg1Lx79w1s5zbhpZsNKFeZiDLi3cFju8jWEtE4PMuP83JXc+u5C2iv Yj1M5v555NQxM+AanqoqhwiIMGwMR62P7o4wIQdnV2FpEjKtm1DH19ML/7SjB7PeoYIb0n 73jOyLcOsgdJbgds+YrOtryg6jODHsEOjRqpx5Sg9VSbPM2Toq+vzhQDOX2O7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YXcGq6TKRz1PW2; Tue, 14 Jan 2025 17:55:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50EHtFEf072650; Tue, 14 Jan 2025 17:55:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50EHtFwt072647; Tue, 14 Jan 2025 17:55:15 GMT (envelope-from git) Date: Tue, 14 Jan 2025 17:55:15 GMT Message-Id: <202501141755.50EHtFwt072647@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9a2ae72421cd - main - libthr: switch thread and sleepq memory allocator to crt from libc malloc List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a2ae72421cd75c741984f63b8c9ee89346a188d Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9a2ae72421cd75c741984f63b8c9ee89346a188d commit 9a2ae72421cd75c741984f63b8c9ee89346a188d Author: Konstantin Belousov AuthorDate: 2025-01-14 09:06:58 +0000 Commit: Konstantin Belousov CommitDate: 2025-01-14 17:55:08 +0000 libthr: switch thread and sleepq memory allocator to crt from libc malloc There are more complex interactions between malloc and libthr initialization that can happen if libthr functions are called from ELF object' constructors, before libthr is initialized. Break the dependencies loop by using the private allocator with controlled init. Reported by: yuri Reviewed by: markj, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D48454 --- lib/libthr/thread/thr_list.c | 4 ++-- lib/libthr/thread/thr_sleepq.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c index bca2bfc75fef..bbc1d2899cb9 100644 --- a/lib/libthr/thread/thr_list.c +++ b/lib/libthr/thread/thr_list.c @@ -150,7 +150,7 @@ _thr_alloc(struct pthread *curthread) if (total_threads > MAX_THREADS) return (NULL); atomic_add_int(&total_threads, 1); - thread = calloc(1, sizeof(struct pthread)); + thread = __thr_calloc(1, sizeof(struct pthread)); if (thread == NULL) { atomic_add_int(&total_threads, -1); return (NULL); @@ -222,7 +222,7 @@ thr_destroy(struct pthread *curthread __unused, struct pthread *thread) _sleepq_free(thread->sleepqueue); if (thread->wake_addr != NULL) _thr_release_wake_addr(thread->wake_addr); - free(thread); + __thr_free(thread); } /* diff --git a/lib/libthr/thread/thr_sleepq.c b/lib/libthr/thread/thr_sleepq.c index d7de9ab4e25a..9c680acd0ac0 100644 --- a/lib/libthr/thread/thr_sleepq.c +++ b/lib/libthr/thread/thr_sleepq.c @@ -62,7 +62,7 @@ _sleepq_alloc(void) { struct sleepqueue *sq; - sq = calloc(1, sizeof(struct sleepqueue)); + sq = __thr_calloc(1, sizeof(struct sleepqueue)); TAILQ_INIT(&sq->sq_blocked); SLIST_INIT(&sq->sq_freeq); return (sq); @@ -71,7 +71,7 @@ _sleepq_alloc(void) void _sleepq_free(struct sleepqueue *sq) { - free(sq); + __thr_free(sq); } void