From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 19D9B1F59D for ; Sat, 3 Sep 2022 11:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662204021; bh=r72MCQvN0IkgsF35HTRsgW6j3hSqlIpCbm44a4FSbrg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JFgnIlHz2toMQSSfwqBi0io5hCpcKM511ZsDWw2DtPreUQWpzf67wh8IXyxd6Jh3F 2RY3k5qkEHceJ2c6U0bds8OdbfkTmzcRQOZF92hMOr3viw0Ko76SYFye3knLnG97oj zRYr7shew7rcROsHKPhgrT0KVD238kCBKFqTtQJU= From: Eric Wong To: mwrap-public@80x24.org Subject: [PATCH 1/2] Ractor compatibility Date: Sat, 3 Sep 2022 11:20:19 +0000 Message-Id: <20220903112020.2317141-2-e@80x24.org> In-Reply-To: <20220903112020.2317141-1-e@80x24.org> References: <20220903112020.2317141-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can no longer depend on having GVL/GIL when we have a Ruby execution context, so so make `kbuf' thread-specific to avoid data corruption. This was ported from the Perl5 version, since Perl5 has had MVM/Ractor-like abilities with native threads for decades, despite the Perl5 ecosystem largely avoids and discourages threads. --- ext/mwrap/mwrap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/mwrap/mwrap.c b/ext/mwrap/mwrap.c index 1d6baec..90f560e 100644 --- a/ext/mwrap/mwrap.c +++ b/ext/mwrap/mwrap.c @@ -308,7 +308,9 @@ struct alloc_hdr { size_t size; }; -static char kbuf[PATH_MAX + INT2STR_MAX + sizeof(struct alloc_hdr) + 2]; +static MWRAP_TSD char kbuf[ + PATH_MAX + INT2STR_MAX + sizeof(struct alloc_hdr) + 2 +]; static struct alloc_hdr *ptr2hdr(void *p) {