Bug 19247 – Segmentation fault when resolving address with std.socket.getAddress inside a Fiber

Status
NEW
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-09-15T00:10:06Z
Last change time
2024-12-01T16:34:09Z
Assigned to
No Owner
Creator
JR
Moved to GitHub: phobos#9762 →

Comments

Comment #0 by zorael — 2018-09-15T00:10:06Z
Manjaro/Arch x86_64. dmd 2.082, ldc v1.11 from repositories. Resolving an invalid address with no dots, such as "asdf", causes a segmentation fault. Resolving a nonexistent address throws an exception, as it should, and valid addresses resolve fine. Noteworthy is that it started after I moved the resolving into a function run as a Generator Fiber. Calls to getAddress outside of it seem to work fine. Unsure if that's relevant. Tested on two machines running Linux, with dmd and ldc. On a Windows machine however it properly threw a SocketOSException: getaddrinfo error: No such host is known. Reduced example (31 lines) is at the resolveseg branch of https://github.com/zorael/kameloso. > $ git clone https://github.com/zorael/kameloso.git -b resolveseg > $ cd kameloso > $ ./tester > 0x00007ffff7a583a8 in __res_context_hostalias () from /usr/lib/libresolv.so.2 Manually, invalid address: > $ gdb --batch -ex run --args kameloso wefpok > [Thread debugging using libthread_db enabled] > Using host libthread_db library "/usr/lib/libthread_db.so.1". > Attempting to resolve wefpok > > Program received signal SIGSEGV, Segmentation fault. > 0x00007ffff7a583a8 in __res_context_hostalias () from /usr/lib/libresolv.so.2 Manually, valid address: > $ gdb --batch -ex run --args kameloso dlang.org > [Thread debugging using libthread_db enabled] > Using host libthread_db library "/usr/lib/libthread_db.so.1". > Attempting to resolve dlang.org > Success > [Inferior 1 (process 15589) exited normally] Random changes to the source makes it segfault in getenv in libc.so.6 instead. For instance, version/comment out the foreach in resolveFiber in connection.d. > (gdb) bt > #0 0x00007ffff7683b1d in getenv () from /usr/lib/libc.so.6 > #1 0x00007ffff74cd3ae in __res_context_hostalias () from /usr/lib/libresolv.so.2 > #2 0x00007ffff74cd7bd in __res_context_search () from /usr/lib/libresolv.so.2 > #3 0x00007ffff747ce6d in _nss_dns_gethostbyname4_r () from /usr/lib/libnss_dns.so.2 > #4 0x00007ffff772efa2 in gaih_inet.constprop () from /usr/lib/libc.so.6 > #5 0x00007ffff772ffc8 in getaddrinfo () from /usr/lib/libc.so.6 > #6 0x00007ffff7ccffe7 in _D3std6socket18getAddressInfoImplFMAxaMQePS4core3sys5posix5netdb8addrinfoZASQCwQCv11AddressInfo () from /usr/lib/libphobos2.so.0.82 > [...]
Comment #1 by robert.schadek — 2024-12-01T16:34:09Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9762 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB