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

libponyc: resolve relative paths in use "path:..." statements #2964

Conversation

srenatus
Copy link
Contributor

@srenatus srenatus commented Dec 18, 2018

This is for #2936.

The use of pony_realpath (which calls the POSIX realpath underneath)
is convenient, but brings a change in behaviour: before, we have passed
just about anything into prog->libpaths, regardless of the directory's
existence. With realpath, nonexistent directories will make the call
return an error.

To remediate the impact a bit, I've added an errorf() statement.

However, to make this round, I think we might have to either check for
existence in both cases~, or don't do that in either one.~

Update: I've rearrange stuff so that both absolute and relative paths are check (by being passed through pony_realpath. This is a potentially a backwards-incompatible change; I'd think it might be one we can accept, though? Let's discuss this 😃

@srenatus srenatus force-pushed the sr/issue-2936/resolve-use-path-relative-paths branch 2 times, most recently from 6baf622 to da0ec3f Compare December 18, 2018 08:46
@srenatus
Copy link
Contributor Author

I'll have to update the tests. Looks like the basic setup done there doesn't create a TK_PACKAGE to go with the TK_PROGRAM in test/libponyc/program.cc.

Do y'all think this is a good approach at all? Maybe my interpretion of #2936 is off...

@srenatus
Copy link
Contributor Author

I'm struggling with the tests a bit. I can't seem to figure out how to wrap the TK_PROGRAM into a TK_PACKAGE in such a way that the changed use_path would work... (looking at this)

@srenatus srenatus force-pushed the sr/issue-2936/resolve-use-path-relative-paths branch from da0ec3f to a5ccd6d Compare December 27, 2018 17:20
@srenatus
Copy link
Contributor Author

💭 I've taken one step back with a5ccd6d -- it seems like the change would be more in line with how this has worked before if the relative paths are merely appended to the package's path, and not checked for existence. What do you think? 😃

@srenatus
Copy link
Contributor Author

srenatus commented Jan 6, 2019

@mfelsche thanks for helping with the tests! I've pushed another quick commit, attempting to fix this on windows... 🤞

@mfelsche
Copy link
Contributor

mfelsche commented Jan 9, 2019

@srenatus i would suggest to postpone verifying path existence in a separate PR and merge this as is. What do you think?

@mfelsche mfelsche added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Jan 9, 2019
@srenatus
Copy link
Contributor Author

srenatus commented Jan 9, 2019

i would suggest to postpone verifying path existence in a separate PR and merge this as is. What do you think?

Yeah! 😃

if(strlen(locator) > FILENAME_MAX)
return false;

strcpy(absolute, locator);
Copy link
Contributor

Choose a reason for hiding this comment

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

i'd prefer memcpy or strncpy here.

if(strlen(locator) > FILENAME_MAX)
return false;

strncpy(absolute, locator, FILENAME_MAX);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

❌ I'll fix this in another commit soon. 😅

@srenatus srenatus force-pushed the sr/issue-2936/resolve-use-path-relative-paths branch from ba466ff to 628772b Compare January 14, 2019 07:46
@srenatus
Copy link
Contributor Author

@mfelsche I've given this another go, and found a way to make this a bit simpler. What do you think? 😃

@mfelsche
Copy link
Contributor

👍

srenatus and others added 6 commits January 14, 2019 09:53
The use of `pony_realpath` (which calls the POSIX `realpath` underneath)
is convenient, but brings a change in behaviour: before, we have passed
just about anything into `prog->libpaths`, regardless of the directory's
existence. With `realpath`, nonexistent directories will make the call
return an error.

To remediate the impact a bit, I've added an `errorf()` statement.

However, to make this round, I think we might have to either check for
existence in both cases, or don't do that in either one.

Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Signed-off-by: Stephan Renatus <srenatus@chef.io>
by creating a fake package.
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Now, this is relying on path_cat to do copying (including length checks).

Signed-off-by: Stephan Renatus <srenatus@chef.io>
@srenatus srenatus force-pushed the sr/issue-2936/resolve-use-path-relative-paths branch from 628772b to 70bf2c8 Compare January 14, 2019 08:53
@srenatus
Copy link
Contributor Author

No idea what happened on travis. Rebased for good measure, let's see what happens now.

Copy link
Contributor

@mfelsche mfelsche left a comment

Choose a reason for hiding this comment

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

my approval holds.

@mfelsche mfelsche merged commit adeb6e3 into ponylang:master Jan 16, 2019
ponylang-main added a commit that referenced this pull request Jan 16, 2019
@srenatus srenatus deleted the sr/issue-2936/resolve-use-path-relative-paths branch January 16, 2019 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants