From nobody Wed Jul 15 20:19:05 2026 X-Original-To: freebsd-hackers@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 4h0nZS5sysz6lyNK for ; Wed, 15 Jul 2026 20:19:12 +0000 (UTC) (envelope-from cmendon@juniper.net) Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) (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 "*.pphosted.com", Issuer "Sectigo Public Server Authentication CA OV R36" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h0nZQ71r0z3JW3 for ; Wed, 15 Jul 2026 20:19:10 +0000 (UTC) (envelope-from cmendon@juniper.net) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=juniper.net header.s=jnprhpepp0429 header.b=PadDfBe+; dkim=none ("invalid DKIM record") header.d=juniper.net header.s=selector1 header.b=fGQEGBl5; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (mx1.freebsd.org: domain of cmendon@juniper.net designates 148.163.143.35 as permitted sender) smtp.mailfrom=cmendon@juniper.net; dmarc=pass (policy=reject) header.from=juniper.net Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66FHJ9pN990823 for ; Wed, 15 Jul 2026 20:19:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; h= content-type:date:from:message-id:mime-version:subject:to; s= jnprhpepp0429; bh=29qStbdcFhx1JJATwV9CpM759NP6YssIyQn838M4VfY=; b= PadDfBe+uj8+qpqlOj7MYz56NuFEt1/gKklNf0UEumyntihto5tjPZGVevEgbWXT XLva9zx4hXiYrXIBeaK98dopG/tAtJftLOzApRxfa+k+3SMCSs+koHqfYL3y20pY zqtxFUNNb7GhIfNLkGolIOAq86QjjHDyqoPsoTbp0W3BP/Q7spanP2GHkAc7TUO9 XYrnxI7cb8pLlyBXQPVFiFm1FATxrXASWQXBohCCnwsfZVHlzs+vfneudgH4BJuX lBhqQJWwPBEMFjqXq2h0tIJweTeY/29R7EWksD2Mb2Fj5XYEr505EG9+HwIUcZox Q7fUnqfosuD96TKnaGggwQ== Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazon11011022.outbound.protection.outlook.com [52.101.62.22]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 4fed0pvcvj-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Wed, 15 Jul 2026 20:19:08 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G7BNNXWZM3NGoCt9EpgdEeImRlOrrd7D+aUUrHEQm7PyBknrmhy0SUIEPOs4Ja7esgGfixljcZ/L0AM4MkYM0H73Fe+zMvHPfLQuG/vfcxP+RaNSilIoIN8oy7W6TVVZFoNQWQrcr8ai8tDb12XxGZqQv0lkpTzob0No7mQjEjj8elZhcAw0PohVLpVb7f7L/9AHRKCc2mNqWs4IEG2RviBqPIev2xwbeHygiVa1brasbJgsPXOrKrkaFTbOfKGVn7HbCT5rtszY57Qj8HYfIQ3qFcEOpPUwHg0E65zyEhn3g/ydo55m54xOazZj058Pqs79lqKds3Zz3FtJfWyVMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:MIME-Version; bh=29qStbdcFhx1JJATwV9CpM759NP6YssIyQn838M4VfY=; b=f13zZJ3Me2w6gncZtZAeL/ASr7e3SuEaWguqktkdgWSA+ryFSGbPm2VnZ6uWpUSUlos+6/FNWj47XR8g17Md+vVJC6mdYguvsKe7GdgLJnl6LUCmhf1rU7Amz87vm2s5+pJVElBfqQ0OwcO15e0uY9CtHjkgw0k+NkVAuGIVPQE9E5zkZO7WLZDDh+TsaSzKuX8D6vDN5LplGNpDw+bMWZsUhNRrE3rpw5fDdM1ZLGJSdI4uZhAcKk9Sg46oG5tmDdQTY5YbX9w15IA/k1RqhLuOF9VYzS1XxL0mu6Hhex/FFXVfOgaoppMNT1uL8SfBWJ2pv9AqbfWKpsEkZjDvbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=juniper.net; dmarc=pass action=none header.from=juniper.net; dkim=pass header.d=juniper.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=29qStbdcFhx1JJATwV9CpM759NP6YssIyQn838M4VfY=; b=fGQEGBl5QtRhoBMAxHVnmfNErE8fMqJCF4WSmWtMRw4h91Q7axx/im3Y69Wt7il0/BWSM0tX+mwmBn3qcOJCr6nJ+NdRQKgCsdRX9RscoKPjxOncN5w+eCLnkdKBl8F2fqFtYK975krS/0yGu8MAwnanULVi1uQDxWbtbLj1ZxI= Received: from DS0PR05MB10016.namprd05.prod.outlook.com (2603:10b6:8:f1::7) by CH8PR05MB11072.namprd05.prod.outlook.com (2603:10b6:610:2b9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.20; Wed, 15 Jul 2026 20:19:05 +0000 Received: from DS0PR05MB10016.namprd05.prod.outlook.com ([fe80::70ec:36fb:1b61:612a]) by DS0PR05MB10016.namprd05.prod.outlook.com ([fe80::70ec:36fb:1b61:612a%4]) with mapi id 15.21.0223.008; Wed, 15 Jul 2026 20:19:05 +0000 From: Chanda Mendon To: "freebsd-hackers@freebsd.org" Subject: jemalloc: NULL arena deref when per-thread arena creation fails under mlockall(MCL_FUTURE) + RLIMIT_MEMLOCK Thread-Topic: jemalloc: NULL arena deref when per-thread arena creation fails under mlockall(MCL_FUTURE) + RLIMIT_MEMLOCK Thread-Index: AQHdFJbU90/Gu5Nv8E+K8CFrZHTXaA== Date: Wed, 15 Jul 2026 20:19:05 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_0633b888-ae0d-4341-a75f-06e04137d755_Enabled=True;MSIP_Label_0633b888-ae0d-4341-a75f-06e04137d755_SiteId=bea78b3c-4cdb-4130-854a-1d193232e5f4;MSIP_Label_0633b888-ae0d-4341-a75f-06e04137d755_SetDate=2026-07-15T20:16:33.4187529Z;MSIP_Label_0633b888-ae0d-4341-a75f-06e04137d755_Name=0633b888-ae0d-4341-a75f-06e04137d755;MSIP_Label_0633b888-ae0d-4341-a75f-06e04137d755_ContentBits=3;MSIP_Label_0633b888-ae0d-4341-a75f-06e04137d755_Method=Standard x-ms-reactions: allow x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS0PR05MB10016:EE_|CH8PR05MB11072:EE_ x-ms-office365-filtering-correlation-id: de1c80f0-cea8-46aa-d183-08dee2ae518b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|23010399003|366016|376014|18002099003|38070700021|56012099006|11063799006|8096899003|10067099003|6133799003|13003099007; x-microsoft-antispam-message-info: GJbWuMbsXNziiKhj5GI+/SIVhpDHJ+xeGxghgyq2rN8t5wnbII10cdWm/VY2yyFfZQOmDRgoTTtuf9p3HNOL4s+CJbYH6omwDZ1D9NXHAGVClzJFPVzAlMkvjIGELBq6CxcQHp6Dh+mH6/BZ6sQDnsaG59/d/WYEDS8JjgmDiDRfVI+txYbXi9iUf2BXgXTK11n8S98NYa0v+IjxOle0I8Sk+UVv55RMfFICm1eGJbOTYE7kMq4I+yAfnPrLOxjZVS8NKOIGWrOJBfWv/LEkAqUTdGrmkYAg2FhQES78aB0BQZthFL4OX6CTkDOdr57ObK5WBqN4lXBcpfsfubOXGKQgpdqED7eek0m+bXxrwbhaS+BK0Vg1q/KQU+k306XWvVPeXl2ATX/imsJD1vIfSStfTPzZLFN/4mQVgJF97kLHZFbCpnQcBARaFhTN8oPqafEwHdea2s0mReA1+JLlzU1T4oWSPLBVONF5O28lKGmcSAbywJ5kS1KfTV1PdE+D27K+PPHpWm7ZNlSjVz2w0p08EsZNQCcVvKSYfo7cA3dDUeYBwCqZcWTfA0d4J2cvxNFArMCsl5NUqxwGvYPe2055iN9mSjlMMHIzcx6HBBB5HwDv0ihA+GD4fnjW6CpoL26/Z9Yikflyd+swc8XePXzbdm1J/JVRCWH2xjwFPh7tNcvRTYbySFN2aDXUVZpgWiZgYE80ZLeWZROmBvR2dSTlfMMlP1viOXRtE6fzWDE= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR05MB10016.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(23010399003)(366016)(376014)(18002099003)(38070700021)(56012099006)(11063799006)(8096899003)(10067099003)(6133799003)(13003099007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9BVG7Qx9L207hHS8DZApAWh0zT3hs1O5v03yKgr1M3zBe8N0ox0pJX7whyV2?= =?us-ascii?Q?acCRLitWPinMxonKowx7sZ3jNqqmUcINJstgJIO5PLAe49+Sy0R8aeJhY2SM?= =?us-ascii?Q?ECrbeZldToiFVdEgFruwXDI7f6eupO4TUgZllr4DYqi6+i/MYuewO8scRXYt?= =?us-ascii?Q?5P9NrA8arOQXOa3w41BEuz6cQhqizFrLNAl2Jl+mwanCnv9a1I9CCGF4E0pP?= =?us-ascii?Q?5pyZZd1JSuy9tEJOhaAAj4ArFUUFIF+oWn5UwImx87GARgwc1sw/4XDGhLBQ?= =?us-ascii?Q?fvLdJZqWjcsaQowdi3qEYRSm7L+mJxxNr6G8qWXIJtG/mR3/q5iUV+yRhI9I?= =?us-ascii?Q?mcbVjmZTuyxBRPsUT48emOaBesLK9AkQ7Wz8R+vWKyWsFRtjWquhMTrl4/Wl?= =?us-ascii?Q?lhwvfbFDRLFkK2Z0LRLmPN18Z5Je4bMqBt9ah/i4mLckTupqH4XC+imrYpTH?= =?us-ascii?Q?1isr56TwkcsWueoXimt/cBwQBfNImR1NKLIEqui1f1tQ1GgCiSfl0u7Nj4yh?= =?us-ascii?Q?p/RIxqp5iWsjEEEgJ0U+MSITA7mSHzEB1TtOLIQTzcuXzX7LftdOG3Ivmr1z?= =?us-ascii?Q?qDgUWgbDMfPHxp1taZnDSIS8GymM7MY7Jx3fTVmjM3NbO342pStvlpGfxgE/?= =?us-ascii?Q?wWD9TJqDLbMLrSanxypEvNn3otpWVI+ytHZby7oZsJpT8bySIlnNp8RDHPor?= =?us-ascii?Q?ISmgirDiEyKzYhWxWWM3rulKntyZgUu8PbBntuAiRNsYnJgTREaEcpJN9gv/?= =?us-ascii?Q?kdpeKFwRescXzylm6KKXLSzhdV/em5A5laE/nEfXWOIhlH26Ip0CB949j5VP?= =?us-ascii?Q?R1Aq6jRNEaOl7JnVID6aMy63OAE+VATmcr8oPicmmMxe584EaWPR+nsVgk8/?= =?us-ascii?Q?IN4Uuhyr8FY+dnM3dnBTmvpbMjAYSP1xeunOMU6rvDGRnLWdFg8BrLtP1Uab?= =?us-ascii?Q?3ye0Hu9btPmLW78gagEQwcd+6dFJuvfxqdVpQ3g2UEuRvD5IAFVGxWh2Y0Cs?= =?us-ascii?Q?0b3oWZzGoFQmcl6VY4AglL1fIT8G8nGayD2V9wS5OC2ZDXXfAfv14iueVVtb?= =?us-ascii?Q?IS8h9UUql8Byp0dOJMZkYPuYB5kRd8e2mqzBHmLoHgRGOBZDzf/TZZ3R3SCt?= =?us-ascii?Q?91DrDMds++guvp/6sYDtG3SBybyTBhlwJRjnxba+DC1emWwM2/FmLVgA1Lrc?= =?us-ascii?Q?Q34P4pABJZ4NLE3/HCCyCFuiS1pVmaGeqYDp/hy/4UcKzbAz6GBgQcc3sKB7?= =?us-ascii?Q?A+/L6kDXPi4doUpVWZKL+vfEYKZH3IL222/eUB/x9p1GQsUVHAAlEnv3tfg2?= =?us-ascii?Q?LLFHPJ5IDr5wXcoNOcYSw7JDwvJ2UT8nAmNvaH64LreuxO1ap8fxLGHewnHc?= =?us-ascii?Q?6aCo8tw5N/Zlna0B16cttNZvInyp7CqgFkWiMeFBW9XZBx0ROxmbRdkHIuLv?= =?us-ascii?Q?xvWc+5E30E5wZvJppPmJjmFvGLCq4Qs846k98vRIBUdlkbqpNg7HSCJH0ens?= =?us-ascii?Q?q+K6yXZjQxhP7pqxrgOJK4w24X9GrKnyVxzHtW4g3S6F7MNpoBxSj+HSjI/u?= =?us-ascii?Q?8lI7hXcZV7DyYvwB/+ifeRyKFNS5Ul0EcB7fpVQjPI6kLWQGQzMHk7Xi+/QO?= =?us-ascii?Q?HWiRW6qVL84MK4W4flWs2He+H4ZCrX6gHMNs9oW6bOLU2asLnR3cZwXoEnsc?= =?us-ascii?Q?GOPwLZZsewi81dpaxSjVbGYB3KF9mxOSIaX+I6qSWcBy7EXzjpRVG+55vGwA?= =?us-ascii?Q?jyGi7EV0dA=3D=3D?= Content-Type: multipart/alternative; boundary="_000_DS0PR05MB100164E90138A1F355310DCD1B4F82DS0PR05MB10016na_" List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Exchange-RoutingPolicyChecked: o8e2pMJEIXKwzgihnxU0q+CZJV6ti3BT5Nd4RJ4ADVgc6g7LlD587jIGhsvolapZU0yFDY2BAuGztHjaV7Rg69dNrcaGFwCoqNS6QvLhb8tNgiCLJjrqRrUXkbkk0fiatZvSKp2vUsp/137UouUkke51Twl70UNZUdhYJjdeOPyh2fFfTFNDAIkJlpo9xCzdww69qTTrE5P6v3hb7y3Nyjw00PLMFDkV3aS/pQ53kPnHmeSnx2MHAjLYd5iJ0SlAnei3aNvhnnz35SiEJfccScaEmuLhg5zRm/OWxusdBKdPiWQP2zrU/PINghwoPwE9lD/J/pLTU021DL562v7f1A== X-OriginatorOrg: juniper.net X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS0PR05MB10016.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: de1c80f0-cea8-46aa-d183-08dee2ae518b X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jul 2026 20:19:05.3421 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bea78b3c-4cdb-4130-854a-1d193232e5f4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Ry+YAr5UHj96IusMm4G6F/h4S56g+DL/D/IBf/EbpE6w+WTGl4Xrr8s0mDTZkbPLAQtzsXWztHTRcVLwpgWnRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH8PR05MB11072 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE1MDIwMiBTYWx0ZWRfX2f4BX7I7EayJ Y2TZRyO6Ac5gX/6pk3eqjOXhUhpCyECNeDK+QqsFoomtbpIQCw3/aqneU6IdXclcN0YPJFsNE5d 3Sz1qqIJo/N1n9FO6NAPFszWNt95jO9ZlBdhBS1qrVKuHSAW1N5hIMBRCzvSYjSa3f5cR3n01PW P6J14BY82/v7ZOYSQNQpUWk71RF4G+yCGGbNfyPvMJuJFjltRUKeT4IUWuGIopVIAgwHxkUW6q+ 5kdPaJl3KQ/kA1pjVQ6sJvUog4QGbb8wCdjZrb6fEZSdmCQt8k2x5s+OVJd+4MqarH21rf4Z7Rf +uUG36+K0FcwwvQEu03wqv1ia5mLFjkQtsmHhCSMeymZWF9g1yYHFBHX8F3fU55Vl1JutOLxiir 4uwciGTLMU1cd7bH8c4NqeZ3NAtI0gpBhIY4zLR3aKJvevbGDN7GBtVPRuseLd5xD98dJkwkH9J eM5/eNBBKj1BuensLdQ== X-Authority-Analysis: v=2.4 cv=Z/3c2nRA c=1 sm=1 tr=0 ts=6a57eb3d cx=c_pps a=OTtHDJnq+OHIMh0/YV57GA==:117 a=z/mQ4Ysz8XfWz/Q5cLBRGdckG28=:19 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=xqWC_Br6kY4A:10 a=RAioF0-LDSMA:10 a=rhJc5-LppCAA:10 a=VkNPw1HP01LnGYTKEx00:22 a=gQcMVamqm3wCPoSYhaRC:22 a=3haJ9R1Aw3gUfsUHDaCR:22 a=NEAV23lmAAAA:8 a=xGkPdIO_pPlWT8uVGocA:9 a=CjuIK1q_8ugA:10 a=kZvKcUIG-0mxBVsU6y8A:9 a=9-BGs_1bDGALjKzq:21 a=_W_S_7VecoQA:10 X-Proofpoint-ORIG-GUID: bkQJt87uU5ikCw7Gv3sKW7xPt-wAKYJu X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE1MDIwMiBTYWx0ZWRfX1QBut7sZS1np s6INWWMlXl8TMDsrL678iYhdGB2h0rsehcmQ8wk1tFSMtAPHDr8l069O7mqbz51Fd0suOVaeOq0 44ln6BZZPnBMNXqTxLzsj+SXbxY2R0M= X-Proofpoint-GUID: bkQJt87uU5ikCw7Gv3sKW7xPt-wAKYJu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-15_04,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Reason: orgsafe X-Proofpoint-Spam-Details: rule=outbound_safe policy=outbound score=0 spamscore=0 phishscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 suspectscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=orgsafe scancount=1 engine=8.22.0-2606150000 definitions=main-2607150202 X-Spamd-Result: default: False [-2.53 / 15.00]; ARC_ALLOW(-1.00)[microsoft.com:s=arcselector10001:i=1]; URI_COUNT_ODD(1.00)[3]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_SPAM_LONG(0.97)[0.966]; DMARC_POLICY_ALLOW(-0.50)[juniper.net,reject]; RWL_MAILSPIKE_EXCELLENT(-0.40)[148.163.143.35:from]; R_SPF_ALLOW(-0.20)[+ip4:148.163.143.35]; R_DKIM_ALLOW(-0.20)[juniper.net:s=jnprhpepp0429]; RCVD_IN_DNSWL_LOW(-0.10)[148.163.143.35:from]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_EQ_ADDR_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; R_DKIM_PERMFAIL(0.00)[juniper.net:s=selector1]; RCVD_COUNT_THREE(0.00)[4]; DKIM_MIXED(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[juniper.net:+,juniper.net:~]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; ASN(0.00)[asn:22843, ipnet:148.163.143.0/24, country:US]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; MISSING_XM_UA(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[52.101.62.22:received] X-Rspamd-Queue-Id: 4h0nZQ71r0z3JW3 X-Spamd-Bar: -- --_000_DS0PR05MB100164E90138A1F355310DCD1B4F82DS0PR05MB10016na_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, We root-caused a deterministic ntpd crash on a FreeBSD 15-based system to a NULL-pointer dereference inside jemalloc that occurs whenever creation of a per-thread arena fails. We have two candidate fixes and would appreciate review. (Thanks to Justin Hibbits for suggesting this list.) THE BUG Environment that exposes it: - the process sets RLIMIT_MEMLOCK to 32MB, then calls mlockall(MCL_CURRENT|MCL_FUTURE). ntpd does this when built with DFLT_RLIMIT_MEMLOCK=3D32; FreeBSD base builds with -1 so stock ntpd is unaffected, our vendor build used 32. - wired memory sits close to the limit (~30MB of 32MB here) - a new thread performs its first malloc Sequence, all in contrib/jemalloc: 1. First malloc in a thread with no bound arena -> arena_choose_impl() -> arena_choose_hard() [src/jemalloc.c] 2. All initialized arenas are busy and a free slot exists, so arena_choose_hard() calls arena_init_locked(). The new arena's base mmap must be wired immediately (MCL_FUTURE) and would exceed RLIMIT_MEMLOCK, so mmap fails -> arena_init_locked() returns NULL -> arena_choose_hard() returns NULL. 3. In arena_choose_impl() [include/jemalloc/internal/jemalloc_internal_inlines_b.h]: ret =3D arena_choose_hard(tsd, internal); assert(ret); <- compiled out in production if (tcache_available(tsd)) { ... tcache_arena_associate(tsdn, tcache, ret); <- ret =3D=3D NU= LL 4. tcache_arena_associate() does malloc_mutex_lock(tsdn, &arena->tcache_ql_mtx); With arena =3D=3D NULL this computes offsetof(arena_t, tcache_ql_mtx= ) plus the lock offset (0x2818 in our build) and faults. FIX CANDIDATE 1 - fail the allocation (arena_choose_impl): ret =3D arena_choose_hard(tsd, internal); if (unlikely(ret =3D=3D NULL)) { return NULL; /* malloc fails with ENOMEM */ } Smallest diff. However, the allocation fails despite free space in the already-initialized arenas, and the thread retries arena creation on every subsequent malloc. FIX CANDIDATE 2 - fall back to the least-loaded existing arena (arena_choose_hard): The selection scan leaves in choose[j] the index of the initialized arena with the fewest bound threads. The creation path overwrites it with the free-slot index, so save it first and fall back on failure: unsigned saved_choose =3D choose[j]; /* Initialize a new arena. */ choose[j] =3D first_null; arena =3D arena_init_locked(...); if (arena =3D=3D NULL) { /* * Creation failed (e.g. mmap ENOMEM under * mlockall(MCL_FUTURE) + RLIMIT_MEMLOCK). Fall back to * the least-loaded existing arena rather than returning * NULL, which the caller dereferences. */ choose[j] =3D saved_choose; if (!!j =3D=3D internal) ret =3D arena_get(tsd_tsdn(tsd), choose[j], false); } else { is_new_arena[j] =3D true; if (!!j =3D=3D internal) ret =3D arena; } ... arena_bind(tsd, choose[j], !!j); Arena 0 is guaranteed initialized (asserted just above the scan), so the fallback cannot itself be NULL. The thread permanently shares an arena, but allocation keeps working; if the shared arena can't grow later, the normal extent-allocation failure path makes malloc return NULL gracefully. QUESTIONS 1. Any correctness issues with either fix, particularly fix 2's binding of the thread to the fallback arena? 2. Which fix is preferable for FreeBSD? 3. Should this go to upstream jemalloc (github.com/jemalloc/jemalloc) as well? The assert-only NULL guard in arena_choose_impl() is upstream code, not a FreeBSD-local change. Thanks, Chanda Juniper Business Use Only --_000_DS0PR05MB100164E90138A1F355310DCD1B4F82DS0PR05MB10016na_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

  Hi,


  We root-caused a deterministic ntpd crash= on a FreeBSD 15-based system

  to a NULL-pointer dereference inside jema= lloc that occurs whenever

  creation of a per-thread arena fails.&nbs= p; We have two candidate fixes and

  would appreciate review.  (Thanks to= Justin Hibbits for suggesting this

  list.)


  THE BUG


  Environment that exposes it:

    - the process sets RLIMIT_MEM= LOCK to 32MB, then calls

      mlockall(MCL_CURR= ENT|MCL_FUTURE).  ntpd does this when built with

      DFLT_RLIMIT_MEMLO= CK=3D32; FreeBSD base builds with -1 so stock ntpd

      is unaffected, ou= r vendor build used 32.

    - wired memory sits close to = the limit (~30MB of 32MB here)

    - a new thread performs its f= irst malloc


  Sequence, all in contrib/jemalloc:=


    1. First malloc in a thread w= ith no bound arena ->

       arena_choos= e_impl() -> arena_choose_hard()   [src/jemalloc.c]


    2. All initialized arenas are= busy and a free slot exists, so

       arena_choos= e_hard() calls arena_init_locked().  The new arena's

       base mmap m= ust be wired immediately (MCL_FUTURE) and would exceed

       RLIMIT_MEML= OCK, so mmap fails -> arena_init_locked() returns NULL

       -> arena= _choose_hard() returns NULL.


    3. In arena_choose_impl()

       [include/je= malloc/internal/jemalloc_internal_inlines_b.h]:


         = ;  ret =3D arena_choose_hard(tsd, internal);

         = ;  assert(ret);              &= nbsp;     <- compiled out in production

         = ;  if (tcache_available(tsd)) {

         = ;      ...

         = ;      tcache_arena_associate(tsdn, tcache, r= et);  <- ret =3D=3D NULL


    4. tcache_arena_associate() d= oes


         = ;  malloc_mutex_lock(tsdn, &arena->tcache_ql_mtx);<= /p>


       With arena = =3D=3D NULL this computes offsetof(arena_t, tcache_ql_mtx)

       plus the lo= ck offset (0x2818 in our build) and faults.


  FIX CANDIDATE 1 - fail the allocation (ar= ena_choose_impl):


      ret =3D arena_cho= ose_hard(tsd, internal);

      if (unlikely(ret = =3D=3D NULL)) {

         = ; return NULL;            /* malloc fail= s with ENOMEM */

      }


  Smallest diff.  However, the allocat= ion fails despite free space in

  the already-initialized arenas, and the t= hread retries arena creation

  on every subsequent malloc.


  FIX CANDIDATE 2 - fall back to the least-= loaded existing arena

  (arena_choose_hard):


  The selection scan leaves in choose[j] th= e index of the initialized

  arena with the fewest bound threads. = ; The creation path overwrites it

  with the free-slot index, so save it firs= t and fall back on failure:


      unsigned saved_ch= oose =3D choose[j];

      /* Initialize a n= ew arena. */

      choose[j] =3D fir= st_null;

      arena =3D arena_i= nit_locked(...);

      if (arena =3D=3D = NULL) {

         = ; /*

         = ;  * Creation failed (e.g. mmap ENOMEM under

         = ;  * mlockall(MCL_FUTURE) + RLIMIT_MEMLOCK).  Fall back to

         = ;  * the least-loaded existing arena rather than returning=

         = ;  * NULL, which the caller dereferences.

         = ;  */

         = ; choose[j] =3D saved_choose;

         = ; if (!!j =3D=3D internal)

         = ;     ret =3D arena_get(tsd_tsdn(tsd), choose[j], = false);

      } else {

         = ; is_new_arena[j] =3D true;

         = ; if (!!j =3D=3D internal)

         = ;     ret =3D arena;

      }

      ...

      arena_bind(tsd, c= hoose[j], !!j);


  Arena 0 is guaranteed initialized (assert= ed just above the scan), so

  the fallback cannot itself be NULL. = The thread permanently shares an

  arena, but allocation keeps working; if t= he shared arena can't grow

  later, the normal extent-allocation failu= re path makes malloc return

  NULL gracefully.


  QUESTIONS


  1. Any correctness issues with either fix= , particularly fix 2's

     binding of the thread t= o the fallback arena?

  2. Which fix is preferable for FreeBSD?

  3. Should this go to upstream jemalloc (<= a href=3D"http://github.com/jemalloc/jemalloc" target=3D"_blank" data-outlo= ok-id=3D"1c558fdd-7982-4d3e-a022-db7af97a8143" style=3D"color: rgb(0, 0, 0)= ; margin-top: 0px; margin-bottom: 0px;">github.com/jemalloc/jemalloc)

     as well?  The asse= rt-only NULL guard in arena_choose_impl() is

     upstream code, not a Fr= eeBSD-local change.


  Thanks,

  Chanda



Juniper Business Use Only

--_000_DS0PR05MB100164E90138A1F355310DCD1B4F82DS0PR05MB10016na_--