Bug 4951 – InternetAddress fails to resolve host when multithreading.
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-09-27T20:30:00Z
Last change time
2010-10-19T06:17:29Z
Assigned to
nobody
Creator
jcao219
Comments
Comment #0 by jcao219 — 2010-09-27T20:30:58Z
When multiple instances of std.socket's InternetAddress are created, "std.socket.AddressException: Unable to resolve host 'www.google.com'"
On Linux, it works.
If you take out the threading, this works fine.
import core.thread;
import std.socket;
import std.stdio;
void test() {
auto a = new InternetAddress("www.google.com", 80);
a = new InternetAddress("www.google.com", 80);
writeln("Connected successfuly.");
}
void main() {
auto thr = new Thread(&test);
thr.start();
}
Build 9/27/2010 on both Windows XP and 7.
Comment #1 by spam — 2010-10-17T17:54:49Z
I get the feeling this is somehow related to 1126 because it does not just happen for InternetAddresses created in multiple threads. Say you create those instances in the main thread and then try to create a Socket in another thread it crashes again saying unable to create socket.
This seems to be an very ancient beast in phobos or whereever and since D trys to be especially concurrency friendly i advice to address this issue in the near future.
Comment #2 by spam — 2010-10-17T17:56:36Z
I raised this one cause it pretty much makes using multithreading in connection with phobos Sockets impossible. Which sucks a lot and blocks my current project (yet again)...
Comment #3 by jcao219 — 2010-10-17T18:21:04Z
Also blocks mine so I advocate the raise
Comment #4 by spam — 2010-10-18T13:56:04Z
(In reply to comment #3)
> Also blocks mine so I advocate the raise
Did you workaround it anyhow ? I cannot think of anything even remotly possible without heavily changing the whole design ;(
Comment #5 by spam — 2010-10-18T14:54:06Z
i rechecked this issue and the reproduction code.
the following code reproduces the crash for sure ( the original code did not, at least under dmd2045 )
[CODE]
import core.thread;
import std.socket;
import std.stdio;
void test() {
auto a = new InternetAddress("www.google.com", 80);
writeln("Connected successfuly.");
}
void main() {
auto thr = new Thread(&test);
thr.start();
scope(failure) writefln("crash");
foreach(i; 0..10)
auto a = new InternetAddress("www.google.com", 80);
}
[/CODE]