Don't enumerate io->blocking_operations if fork generation is different. (#13359)

This commit is contained in:
Samuel Williams 2025-05-16 14:14:23 +09:00 committed by GitHub
parent 35000ac2ed
commit a0fe0095ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-05-16 05:14:37 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>

5
io.c
View File

@ -5692,9 +5692,14 @@ rb_io_memsize(const rb_io_t *io)
if (io->writeconv) size += rb_econv_memsize(io->writeconv);
struct rb_io_blocking_operation *blocking_operation = 0;
// Validate the fork generation of the IO object. If the IO object fork generation is different, the list of blocking operations is not valid memory. See `rb_io_blocking_operations` for the exact semantics.
rb_serial_t fork_generation = GET_VM()->fork_gen;
if (io->fork_generation == fork_generation) {
ccan_list_for_each(&io->blocking_operations, blocking_operation, list) {
size += sizeof(struct rb_io_blocking_operation);
}
}
return size;
}