www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13573] New: std.net.curl doesn't handle exceptions in callbacks


          Issue ID: 13573
           Summary: std.net.curl doesn't handle exceptions in callbacks
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
import std.net.curl;

void main()
    auto http = HTTP("dlang.org/non-existing-url");
    http.onReceiveStatusLine = (HTTP.StatusLine s) {
        if (s.code != 200)
            throw new Exception("Request failed.");
    http.method = HTTP.Method.head;

dmd -L-lcurl -run bug


This program segfaults because the D exception handling cannot unwind through
the C stack of libcurl. What's needed here is either a nothrow requirement on
the callbacks or an exception catch/rethrow mechanism.

Oct 04 2014