delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/04/10/02:14:54

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 53A6Erbc3115437
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 53A6Erbc3115437
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=o39ZJKWm
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDAEA383A28A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1744265692;
bh=cv2+zKpjsTp+O5jGdk1e50IFGvgbVRP2UemNzAbKMhs=;
h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=o39ZJKWmalVcTDxwapBVLQx6RbiP6R04tn7Uv8ls+bEqsKBuhruomsFzJuhU0goJq
KZn+eGyGxqSVu+vDKJQrSNz1UzjtfLPh2xYKd+MCSzpJZCuTiIr73owgqSlrV0SGhe
9xvRjcS6+NZ5GBegrykgbDWB6ANMDP5nd43ETqx8=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42C253858D21
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 42C253858D21
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744265634; cv=none;
b=tmT7haCIYZTS391ZU6OjIf8Dz/4/hVHFW1MEU1xTvI0S+SGML7tC+KRgQ8P4YaoLAVsm/VNLfTEmwClu8HBb3Cf1f1B5V3JbiDXj9uWHabxz18+qGLQd2fEgK3i99e21VNrDvC8IeScz0J9pusSYywbWXGJMc6b9ZFBJf6RBDwQ=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1744265634; c=relaxed/simple;
bh=iz4TyIODbJHHggwRI5AyzQqdkfuOAomyeJtBWToFH4w=;
h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;
b=YHhG8lfYWKr/zhqpIuGtI6rFH4xtrnhXQ/z1DXIaI2T0WwDMIB0TbWcg3GHFC6WVyi79iLQumQYIYD8vVOebvrYzPW2Ei0mI1XZfzW2yG8oIbC6cNdZZLgDcsvXfqFgug+ysHILXj3F4na76iz2Huc6xhNklDOrAt9zWTiXy5fA=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42C253858D21
Date: Wed, 9 Apr 2025 23:13:53 -0700 (PDT)
X-X-Sender: jeremyd AT resin DOT csoft DOT net
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: pthread_atfork vs dlopen/dlclose
In-Reply-To: <2021152719.99592.1744265074916@mail.yahoo.com>
Message-ID: <b150c1e4-b3cd-4f90-8548-0c5f287948d4@jdrake.com>
References: <07665688-8199-2e80-cdfe-abeaa6f56ba7 AT jdrake DOT com>
<2021152719 DOT 99592 DOT 1744265074916 AT mail DOT yahoo DOT com>
MIME-Version: 1.0
X-Content-Filtered-By: Mailman/MimeDel 2.1.30
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Jeremy Drake via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Jeremy Drake <cygwin AT jdrake DOT com>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
Note-from-DJ: This may be spam
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 53A6Erbc3115437

On Thu, 10 Apr 2025, Kevin Schnitzius via Cygwin wrote:

> On Wednesday, April 9, 2025 at 06:54:34 PM EDT, Jeremy Drake via Cygwin <cygwin AT cygwin DOT com> wrote:
>
> > The recent issue with pthread_atfork handlers reminded me of a scenario
> > that I know glibc handles, but it seems that Cygwin does not.  Test case:
>
> <... code that loads a shared lib, registers some functions in shared lib with pthread_atfork(), unloads the shared lib, and crashes on fork...>
>
> Calling functions in an unloaded library should result in undefined behavior.
>
> However, further investigation reveals that the Linux pthread_atfork() registered functions are not being called and POSIX does not proved a mechanism for un-registering these functions.   Note: pthread_atfork() is not bumping the ref count on the shared lib--those functions are definitely unavailable after the dlclose()
>
> In the Cygwin version, calling the functions in the unloaded library when the fork happens causes the crash.
>
> This seems to be a bug with fork(), if it is a bug at all.

I did a quick search, and found a write-up of *my* bug report :D

https://developers.redhat.com/articles/2022/12/14/how-we-addressed-unforeseen-use-case-pthreadatfork

"Now, dlclose()'ing a module means that any fork handlers registered by it
should not be executed after the dlclose and should therefore implicitly
be deregistered."

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019