Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dmd.root.filename: Fix FileName.canonicalPath() regression on Windows #11293

Merged
merged 1 commit into from Jun 19, 2020

Conversation

kinke
Copy link
Contributor

@kinke kinke commented Jun 18, 2020

The assertion was wrong and guaranteed to fail when enabled (my bad in #11089).
This is a reboot of #11111.

Also make sure to return a new root.rmem-managed memory allocation in all cases, i.e., not the malloc'd memory directly for the canonicalize_file_name version. E.g., the memory is released via mem.xfree() in FileName.safeSearchPath().

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#11293"

Copy link
Member

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need a comment

Comment on lines +984 to +987
scope(exit) .free(path.ptr);
if (path !is null)
return path.toDString;
return xarraydup(path.toDString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment, e.g. // Make sure we consistently return Mem-allocated memory. Otherwise someone is bound to see this and think it can be trivially improved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent such an 'improvement', I've added the FileName.free() call in the test. But that needs an enabled GC (-lowmem) to hopefully produce an error.

@WalterBright
Copy link
Member

I recently noticed that when I compiled dmd with asserts enabled, and ran without any arguments, it assert failed in root/filename.d. Is this that problem?

@kinke
Copy link
Contributor Author

kinke commented Jun 18, 2020

Very likely, as DMD uses this function when looking up the config file IIRC.

The assertion was wrong and guaranteed to fail when enabled (my bad).
This is a reboot of dlang#11111.

Also make sure to return a new root.rmem-managed memory allocation in
all cases, i.e., not the malloc'd memory directly for the
canonicalize_file_name version. E.g., the memory is released via
mem.xfree() in FileName.safeSearchPath().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Regression PRs that fix regressions
Projects
None yet
4 participants