Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqbyg-009cZA-9s for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 18:31:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uqbyf-00Cjgj-PB for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 18:31:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqbyf-00Cjgb-G0 for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 18:31:34 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqbyd-001oQ9-16 for pgsql-hackers@postgresql.org; Mon, 25 Aug 2025 18:31:33 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-88432daa703so177745139f.1 for ; Mon, 25 Aug 2025 11:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756146689; x=1756751489; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2LrlXISvIC59fOY0iuEJQ60bKJ0+8EDwGgBLKJlhBbY=; b=D6V6ap14LLHVT1NTtWwhH+CDUUra/qB/jDOxjGB4Eh9w8rZ2Fqtuj1C/Ijup6YOF2/ yhO9Dx5JIlWLtq2rK5KMufTgZOSDsKyFcMeBVufUlmj+L/wgQeNENDwLKJlUnAnRtC7y KwY502CMfsMNM4ExQSedV145XkaABn2OIUxZKQlyEG2cNbV98L4LB2WWpoXNST3Jt975 g9PDZADaKu7eXJaqzgK0gbg3ehjnEM2ub0bB3870FeV2k/HMPY3iFodDqA8xn9fV2UJ5 K3tlgKVswV2CbsygCNXw2YnOV2Tj6FkbYJMgVbw3XUxfmBCzMVH7dM65yigP9QzWLbMQ WKNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756146689; x=1756751489; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2LrlXISvIC59fOY0iuEJQ60bKJ0+8EDwGgBLKJlhBbY=; b=fMCTY9WkhyK7nONUIojrQVJjHnGTONMXMuvhvNxgjhbwr9eDb3VxkOSRcIBTfxiRtt L+FOzgo6kT+RxsDXjortsP7POmCFyJ83FLctVaZJ470iTQoovFxLRQN1PwT6hzsb79RE 62vy4ZYFXA3GB2MDmxhiEt2wJelmsQkRigcCPQ0BhHm+qbuUrceCTSovZEofWtD9GGly Lg8MOifjASRVV4fGU0JU2uY3+sKz0/ccj8OykdH7TKsgbtaqh+wnbUTxtk8t8Uc00jXQ 72rZh/RNZVyf8it4qXSiGRCkpvdjiDpcgO7Hi5m2UODVuU/GDeS4wofZsAkVzF7WskhC eTFA== X-Gm-Message-State: AOJu0YxcfqD/wNmqZrJMMJiFtBwRdJAaeCZ6qzpHJFUGSDI0NJ3b21s0 P5Qounu0HW4a59HO3KgBYhLRqrORVfoY410byY6wWRRhWxUq52pBzjk+WUlY9g== X-Gm-Gg: ASbGncv8XipmkjQqK0OFvioXt0Rg4dC6JYVrvDuhBe+2WbFcI26m3bxai+eE0tlmy8h znjOnKPiax1gpKJkhjxVMmRi+4EBaGOKiwmLQBTpXMh1D19xEUk+w1zf5/WVNlEfYqA2L+7ET1W nvM1bm5dPLVjZJAxjoxpKJWlr82iCnBfafRbLYaYrLVmxVWSs8WZprf7cByX40+wK36bq7BRo+b jhm9SXaBmRnfls3Zr+sw6jxF0UqugAZaS2wCGmP3QxB9pAQDc4/eAsQoPxdJOhp9ULuHoFgnAVy ETDkqbdA1tFkcfSSU8Fw81zIf00WaGuDoDvZIFc8IvSPyCzoAdXk9Y6vv/lft9o1TjraiX0QFr1 9F8YwuXU6j2/TjIPIFR2c+rlunW5pG81A8kVeThbjQ5QeJDcKjm0dsiLePEsoQ0ILH2LS2U9yMa Xy3RTQaCqhpb1A X-Google-Smtp-Source: AGHT+IEZSkKDKE6Rlw5WaYkNnL7gUwPkP6A9q7I0cxpS9WfcsZVL5d7kiVDddIqBQBTdQt1WAwyx9A== X-Received: by 2002:a05:6602:1696:b0:886:c53c:4647 with SMTP id ca18e2360f4ac-886c53c49d6mr1340378039f.15.1756146688839; Mon, 25 Aug 2025 11:31:28 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-886ca254528sm476696139f.27.2025.08.25.11.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Aug 2025 11:31:28 -0700 (PDT) Date: Mon, 25 Aug 2025 13:31:26 -0500 From: Nathan Bossart To: Sami Imseih Cc: pgsql-hackers Subject: Re: GetNamedLWLockTranche crashes on Windows in normal backend Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Aug 25, 2025 at 12:58:08PM -0500, Sami Imseih wrote: >> If this fails, why doesn't the call in pgss_shmem_startup() also fail? Was >> pg_stat_statements not loaded via shared_preload_libraries? > > because the array is valid in postmaster, but it's not for a normal backend, > since it's not getting copied. > > Yes, pg_stat_statements was loaded via shared_preload_libraries. Nothing > was done out of the ordinary. > >> And is the >> failure a segfault or a "requested tranche is not registered" error? > > It's a segfault. Oh, I see what's happening. We are never calling GetNamedLWLockTranche() in backends because ShmemInitStruct() always sets *found. I'd argue that calling GetNamedLWLockTranche() outside of an "if (!found)" block in a shmem_startup_hook doesn't follow convention, but the docs have this note: shmem_startup_hook provides a convenient place for the initialization code, but it is not strictly required that all such code be placed in this hook. Like the inaccurate sentence immediately following this one [0], it was added by commit 964152c. IMHO we should adjust the documentation to match reality. [0] https://postgr.es/m/aJ9QIF3g2QQko9wq%40nathan -- nathan