Bug #9352
closed[BUG] rb_sys_fail_str(connect(2) for [fe80::1%lo0]:3000) - errno == 0
Description
I'm seeing this crash attempting to connect to an http unreachable host (127.0.0.1:3000) through Excon, which in turn uses connect_nonblock
.
I'm compiling ruby-trunk at the moment, to try on it as well.
Files
Updated by kain (Claudio Poli) almost 11 years ago
Issue persists with ruby 2.2.0dev (2014-01-03 trunk 44488) [x86_64-darwin13.0]
Updated by normalperson (Eric Wong) almost 11 years ago
- File 0001-socket-preserve-errno-before-rb_sys_fail_-and-friend.patch 0001-socket-preserve-errno-before-rb_sys_fail_-and-friend.patch added
I can't reproduce the issue, but I think it has to do with calling functions which may clobber errno before
finally calling rb_sys_fail.
Can you try the attached patch (or pull request) against trunk?
$ git pull git://80x24.org/ruby.git sock-preserv-errno
The following changes since commit 12b09864056bfb961f06b0ef675b9fc2fabb9238:
- properties. (2014-01-03 01:51:05 +0000)
are available in the git repository at:
git://80x24.org/ruby.git sock-preserv-errno
for you to fetch changes up to aaa0e88d55abcddfdf895508b86fe18e3d6b5cea:
socket: preserve errno before rb_sys_fail_* and friends (2014-01-03 07:24:35 +0000)
Eric Wong (1):
socket: preserve errno before rb_sys_fail_* and friends
ext/socket/socket.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
Updated by tmm1 (Aman Karmani) almost 11 years ago
I can confirm Eric's patch fixes this [BUG] for me in faraday's test suite.
Updated by Anonymous almost 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44490.
Claudio, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
-
ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno
before calling rb_sys_fail_str to prevent [BUG] errno == 0.
Patch by Eric Wong. [ruby-core:59498] [Bug #9352] -
ext/socket/socket.c (rsock_sys_fail_path): ditto
-
ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto
-
ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto
-
ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto
Updated by Anonymous almost 11 years ago
- Status changed from Closed to Open
- Assignee set to naruse (Yui NARUSE)
- % Done changed from 100 to 0
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED
Updated by normalperson (Eric Wong) almost 11 years ago
Thanks for testing. I can't say I like my patch, however, as
it's still error-prone and fragile.
How about some new functions to the C API:
rb_syserr_fail_str(VALUE mesg, int errnum);
rb_syserr_fail(const char *mesg, int errnum);
And deprecate rb_sys_fail and rb_sys_fail_str.
Updated by kain (Claudio Poli) almost 11 years ago
Thanks Eric, patch fixes the issue for me in ruby 2.2.0dev (2014-01-03 trunk 44490) [x86_64-darwin13.0]
Updated by tmm1 (Aman Karmani) almost 11 years ago
@nobu (Nobuyoshi Nakada) cleaned up the patch in r44496, so that can be backported instead of r44490
Updated by naruse (Yui NARUSE) over 10 years ago
- Backport changed from 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: DONE
Updated by naruse (Yui NARUSE) over 10 years ago
- Status changed from Open to Closed