taganaka / SpeedTest

Yet another unofficial speedtest.net client cli interface
331 stars 83 forks source link

Fix segfault in SpeedTestClient::mkSocket #14

Closed speed47 closed 6 years ago

speed47 commented 6 years ago

Replace the use of the non-reentrant gethostbyname() function by the thread-safe gethostbyname_r() one. Those segfaults are more likely to happen with a high number of threads, which is the case when testing high-bandwidth connections.

This is also dependent on the libc/compiler, as the program started to segfault ~100% of the time when attempting to test a Fiber connection with the program compiled under gcc7 where the same program compiled under gcc5 was segfaulting only ~%5 of the time.

taganaka commented 6 years ago

Good catch! Thanks

vlw commented 7 months ago

/usr/bin/ld: CMakeFiles/SpeedTest.dir/SpeedTestClient.cpp.o: in function `SpeedTestClient::mkSocket()': SpeedTestClient.cpp:(.text+0xa58): warning: Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking