Actions
Bug #22391
closedFix propagation of `errno` in `rb_io_maybe_wait`.
Bug #22391:
Fix propagation of `errno` in `rb_io_maybe_wait`.
Description
When a write returns EAGAIN, we call rb_io_wait():
io_write()
io_fwrite()
io_binwrite()
io_binwrite_string()
io_binwrite_string_internal()
...
rb_io_maybe_wait_writable()
rb_io_maybe_wait()
return rb_io_wait(io, events, timeout)
if this wait also fails, it bubbles up to io_write() which reports it:
rb_syserr_new_path_in (after macro resolution) checks for a 0 error
code and aborts in that case:
if (n == 0) {
const char *s = !NIL_P(path) ? RSTRING_PTR(path) : "";
if (!func_name) func_name = "(null)";
rb_bug("rb_sys_fail_path_in(%s, %s) - errno == 0",
func_name, s);
}
Unfortunately, rb_io_wait() can invoke the fiber scheduler, running
arbitrary code that can clobber errno and trigger this rb_bug().
Fix this by preserving errno explicitly across the rb_io_wait() call.
Updated by Anonymous 23 days ago
- Status changed from Open to Closed
Applied in changeset git|c4f93eb297c5723673d961db8eee390cbcdf5069.
io: preserve errno across rb_io_wait() call. (#19121)
[Bug #22391]
Updated by ioquatix (Samuel Williams) 23 days ago
- Subject changed from Fix propagation of `ERRNO` in `rb_io_maybe_wait`. to Fix propagation of `errno` in `rb_io_maybe_wait`.
Updated by k0kubun (Takashi Kokubun) 13 days ago
- Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE
ruby_4_0 133bc46e19102499209b82b0f2958d36f8573bd2.
Updated by nagachika (Tomoyuki Chikanaga) 11 days ago
- Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE
ruby_3_4 eb6033eb5888582319cbbf4d2115fb3df1bd0119 merged revision(s) c4f93eb297c5723673d961db8eee390cbcdf5069.
Actions