Bug #16283
closedA fork in transaction of PG cause Segmentation fault
Description
Call Kernel#fork in transaction of Postgres and call some Socket method in fork's block, then ruby on the child process abort with segmentation fault.
Conceptual code:
MGModel.connection.transaction do
# Do something
fork do
Socket.gethostbyname('localhost') # <- Segmentation fault.
end
end
Expected behavior: The child process successfully exists or raises exception.
Please see attached files for Reproduction code and full error log.
Files
Updated by byroot (Jean Boussier) about 5 years ago
Pretty sure that's the OSX specific bug that got fixed in 2.6.4 or 2.6.5 (This one IIRC but I might be wrong https://bugs.ruby-lang.org/issues/15887).
Can you try with 2.6.5 ?
Updated by jeremyevans0 (Jeremy Evans) about 5 years ago
- Related to Bug #13646: Segmentation fault with postgresql_adapter in Rails added
Updated by jeremyevans0 (Jeremy Evans) about 5 years ago
- Status changed from Open to Third Party's Issue
This looks like the Mac OS getaddrinfo bug. See the part of the C-level backtrace before the crash:
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x1d) [0x7fff7cbf8b5d]
/usr/lib/system/libsystem_trace.dylib(_os_log_preferences_refresh+0x4c) [0x7fff7cc1b90a]
/usr/lib/system/libsystem_trace.dylib(0x7fff7cc1c13d) [0x7fff7cc1c13d]
/usr/lib/system/libsystem_info.dylib(si_destination_compare_rfc6724+0x97e) [0x7fff7cb2fbee]
/usr/lib/system/libsystem_info.dylib(0x7fff7cb2d1f9) [0x7fff7cb2d1f9]
/usr/lib/system/libsystem_info.dylib(0x7fff7cb2cd3f) [0x7fff7cb2cd3f]
/usr/lib/system/libsystem_info.dylib(0x7fff7cb0b6df) [0x7fff7cb0b6df]
/usr/lib/system/libsystem_c.dylib(_isort+0xc1) [0x7fff7cab5e5b]
/usr/lib/system/libsystem_c.dylib(0x7fff7cab5d88) [0x7fff7cab5d88]
/usr/lib/system/libsystem_info.dylib(0x7fff7cb02f2d) [0x7fff7cb02f2d]
/usr/lib/system/libsystem_info.dylib(0x7fff7cb01885) [0x7fff7cb01885]
/usr/lib/system/libsystem_info.dylib(0x7fff7cb00f77) [0x7fff7cb00f77]
/usr/lib/system/libsystem_info.dylib(0x7fff7cb00e7d) [0x7fff7cb00e7d]
/Users/k-omoto/.rbenv/versions/2.6.3/lib/ruby/2.6.0/x86_64-darwin18/socket.bundle(nogvl_getaddrinfo+0xb5) [0x1048ea295]
Many variations of this bug have been reported, see all the bugs linked in #13646. As this crash happens inside a Mac OS system library, there doesn't appear to be anything Ruby can do to fix it.
Updated by doloopwhile@gmail.com (健司 小本) about 5 years ago
FYI:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.5
BuildVersion: 18F132