<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>This is on OSX. I'll have to come up with a functional minimal example. <br><br>On Jan 17, 2013, at 2:13 PM, Maxim Fomin <<a href="mailto:maxim@maxim-fomin.ru">maxim@maxim-fomin.ru</a>> wrote:<br><br></div><blockquote type="cite"><div>Are you debugging this on OSX?<br><br>In linux these three runs fine and throws exceptions because of absent URL. <br>However after adding "<a href="http://dlang.org">dlang.org</a>" argument in each of three cases to watch performance,<br>

valgrind shows memory errors which are finally detected in druntime (gc.gcx.mark, gc.gcx.findpool, etc.),<br>so there is something wrong with curl module or druntime.<br><br>Does valgrind detect errors in your installation for #1 and #3?<br>

<br><div class="gmail_quote">2013/1/17 Sean Kelly <span dir="ltr"><<a href="mailto:sean@invisibleduck.org" target="_blank">sean@invisibleduck.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Here are three variations of code using the curl client.  The first works, the second fails with a segfault, and the third works:<br>
<br>
<br>
#1<br>
<br>
void main() {<br>
   auto http = HTTP();<br>
   go(http);<br>
}<br>
<br>
void go(ref HTTP http) {<br>
   // compose request<br>
   http.perform();<br>
}<br>
<br>
works!<br>
<br>
<br>
#2<br>
<br>
void main() {<br>
   HTTP http;<br>
   init(http);<br>
   go(http);<br>
}<br>
<br>
void init(ref HTTP http) {<br>
   http = HTTP();<br>
}<br>
<br>
void go(ref HTTP http) {<br>
   // compose request<br>
   http.perform();<br>
}<br>
<br>
segfault! (see below)<br>
<br>
<br>
#3<br>
<br>
void main() {<br>
   HTTP http;<br>
   init(http);<br>
   go(http);<br>
}<br>
<br>
void init(ref HTTP http) {<br>
   http.__ctor(null);<br>
}<br>
<br>
void go(ref HTTP http) {<br>
   // compose request<br>
   http.perform();<br>
}<br>
<br>
works!<br>
<br>
<br>
I'm guessing the segfault in the second case is a compiler bug, but I haven't tried to narrow it down yet.  The problem initially came up because I wanted to use the HTTP struct as a class member, and the documented means for initializing it was causing a segfault.  Here's the stack trace:<br>


<br>
<br>
Program received signal EXC_BAD_ACCESS, Could not access memory.<br>
Reason: KERN_PROTECTION_FAILURE at address: 0x00000001000028ec<br>
0x0000000100077803 in D3std3net4curl4HTTP15onReceiveHeaderMFNdDFxAaxAaZvZv12__lambda2026MFxAaZv ()<br>
(gdb) bt<br>
#0  0x0000000100077803 in D3std3net4curl4HTTP15onReceiveHeaderMFNdDFxAaxAaZvZv12__lambda2026MFxAaZv ()<br>
#1  0x0000000100078bfd in D3std3net4curl4Curl15onReceiveHeaderMFNdDFxAaZvZv12__lambda2029MFxAaZv ()<br>
#2  0x0000000100078e75 in _D3std3net4curl4Curl22_receiveHeaderCallbackUxPammPvZm ()<br>
#3  0x00007fff98ed6eb9 in Curl_client_write ()<br>
#4  0x00007fff98ed616f in Curl_http_readwrite_headers ()<br>
#5  0x00007fff98eebe11 in Curl_readwrite ()<br>
#6  0x00007fff98eed709 in Curl_do_perform ()<br>
#7  0x0000000100078a3b in D3std3net4curl4Curl7performMFbZi ()<br>
#8  0x00000001000770f8 in D3std3net4curl4HTTP8_performMFbZi ()<br>
#9  0x0000000100076e9a in D3std3net4curl4HTTP7performMFZv ()<br>
#10 function go(ref HTTP)<br>
#11 function main()<br>
<br>
<br>
Can someone confirm that either the static opCall method that HTTP uses for initialization is bad and should be changed, or that this is a compiler issue?<br>
_______________________________________________<br>
dmd-internals mailing list<br>
<a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br>
</blockquote></div><br>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>dmd-internals mailing list</span><br><span><a href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a></span><br><span><a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a></span></div></blockquote></body></html>