[Issue 13541] New: std.windows.syserror.sysErrorString() should be nothrow
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Sep 27 13:04:42 PDT 2014
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: nobody at puremagic.com
Reporter: bugzilla at digitalmars.com
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'.
--
More information about the Digitalmars-d-bugs
mailing list