D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20810 - Freshly built DMD fails to read config file
Summary: Freshly built DMD fails to read config file
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P1 normal
Assignee: Andrej Mitrovic
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-05-08 17:04 UTC by Andrej Mitrovic
Modified: 2021-01-30 20:26 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2020-05-08 17:04:53 UTC
$ C:\dev\dmd\src>rdmd build.d -v
..\generated\windows\release\64\dmd.exe

It tries to get the canonical name of this path:
C:\dev\dmd\generated\windows\release\64\sc.ini

But it fails at this assertion:
> core.exception.AssertError@dmd\root\filename.d(1011): Assertion failure

This assert fails:
assert(length == fullPathLength);

I've read the docs here: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew

It seems on the second call the count will actually not include the null character, specifically this note from MSDN:

> Note  Although the return value in this case is a length that includes the terminating null character, the return value on success does not include the terminating null character in the count.

I'll submit a PR.
Comment 1 Dlang Bot 2020-05-08 17:11:54 UTC
@AndrejMitrovic updated dlang/dmd pull request #11111 "Fix issue 20810: Freshly built DMD fails to read config file " fixing this issue:

- Fix getting canonical path in GetFullPathNameW
  
  According to MSDN docs, the return value of GetFullPathName
  does *not* count the terminating null character.
  
  In the first call, it *does* include this count because
  a buffer was not specified in that initial call.
  
  Fix Issue 20810

https://github.com/dlang/dmd/pull/11111
Comment 2 moonlightsentinel 2021-01-30 20:26:06 UTC
Fixed by https://github.com/dlang/dmd/pull/11293