about summary refs log tree commit homepage
path: root/ext/mwrap/mwrap.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-09-03 10:50:53 +0000
committerEric Wong <e@80x24.org>2022-09-03 11:06:24 +0000
commitfd15a49eb477b345e97ca3bbd6cde135cd0d6583 (patch)
tree4019aa024fe269ad632ede4dc30cf32177f36a3d /ext/mwrap/mwrap.c
parente6f1dbf1c169b8bd7f2fd3e24d1618eb0ddb2666 (diff)
downloadmwrap-fd15a49eb477b345e97ca3bbd6cde135cd0d6583.tar.gz
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.
Diffstat (limited to 'ext/mwrap/mwrap.c')
-rw-r--r--ext/mwrap/mwrap.c4
1 files changed, 3 insertions, 1 deletions
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)
 {