https://issues.dlang.org/show_bug.cgi?id=13541

          Issue ID: 13541
           Summary: std.windows.syserror.sysErrorString() should be
                    nothrow
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: Phobos
          Assignee: [email protected]
          Reporter: [email protected]

It should be nothrow because it is called by constructors like FileException,
which are themselves exceptions. Exceptions should be buildable without having
"double fault" exceptions happening.

Digging into sysErrorString() there's this:

  if(length == 0)
  {
    throw new Exception(
        "failed getting error string for WinAPI error code: " ~
        sysErrorString(GetLastError()));
  }

This should be an assert because:

1. sysErrorString()'s argument should ONLY be values returned by Windows APIs
like GetLastError(), and so this should always succeed.

2. recursively calling sysErrorString() with the SAME value will cause a stack
overflow crash, not any usable exception.

Following this fix, sysErrorString() should be marked as 'nothrow'.

--

Reply via email to