From 12bc2cfaa1a7d4c9490ac25d0a00f80293d28868 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 14 Feb 2026 12:04:14 +0900 Subject: [PATCH] mruby-io: reorder struct mrb_io to keep fd at offset 0 move fd, fd2, pid fields before the bitfield flags while keeping the pointer field last. this preserves the 24-byte struct size (same as 3.4.0) while restoring fd to offset 0 (same as 3.3.0). some external gems (e.g. mruby-polarssl) pass struct mrb_io pointers directly to libraries like mbedtls that expect an int fd at offset 0. the 3.4.0 reorder moved bitfield flags to offset 0, causing these gems to read garbage instead of the file descriptor. fixes #6713 Co-authored-by: Claude --- mrbgems/mruby-io/include/mruby/io.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mrbgems/mruby-io/include/mruby/io.h b/mrbgems/mruby-io/include/mruby/io.h index a12903f15..e76241ba6 100644 --- a/mrbgems/mruby-io/include/mruby/io.h +++ b/mrbgems/mruby-io/include/mruby/io.h @@ -32,6 +32,9 @@ struct mrb_io_buf { }; struct mrb_io { + int fd; /* file descriptor, or -1 */ + int fd2; /* file descriptor to write if it's different from fd, or -1 */ + int pid; /* child's pid (for pipes) */ unsigned int readable:1, writable:1, eof:1, @@ -39,9 +42,6 @@ struct mrb_io { is_socket:1, close_fd:1, close_fd2:1; - int fd; /* file descriptor, or -1 */ - int fd2; /* file descriptor to write if it's different from fd, or -1 */ - int pid; /* child's pid (for pipes) */ struct mrb_io_buf *buf; };