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

Fix win32reg issues #5037 and #4702 #5038

Merged
merged 2 commits into from Sep 8, 2021
Merged

Conversation

reganheath
Copy link
Contributor

Pull request to resolve #5037 and #4702 (issues with win32reg). I have to be honest, I found it very hard to debug and test this due to the complexity of building OTP on windows. I managed to build it in WSL, but of course this doesn't help as the code in Q is windows only.

@CLAassistant
Copy link

CLAassistant commented Jul 9, 2021

CLA assistant check
All committers have signed the CLA.

@garazdawi
Copy link
Contributor

Hello! Github actions build windows installers that you can download and test your changes with. If you click on the actions tabs there is an artifacts dropdown where you can download otp_prebuilt_win32.

@reganheath
Copy link
Contributor Author

Awesome. I have downloaded the windows installer, installed it on a clean VM, then run my test cases in an escript. I found one mistake, corrected it, and I believe the changes are good.

@garazdawi garazdawi added the team:VM Assigned to OTP team VM label Jul 12, 2021
@sverker sverker changed the title Fix #5037 and #4702 Fix win32reg issues #5037 and #4702 Aug 10, 2021
Comment on lines +321 to +326
{
char* key = buf;

result = RegDeleteKey(rp->hkey, key);
reply(rp, result);
}
Copy link
Contributor

@sverker sverker Aug 10, 2021

Choose a reason for hiding this comment

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

Edit: Just ignore me. I was watching the wrong code version and missed the change to win32reg:delete_key. I wrote:

I don't get how this could work (other than pure luck). The data buffer sent for CMD_DELETE_KEY does only contain one byte (the value 7). The pointer buf has been incremented (before the switch) to point just beyond that first and only byte into unknown territory. Passing it as argument to any function is just wrong.

According to RegDeleteKey documentation, the second argument lpSubKey should be the name of the subkey to be deleted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better (as @b-winkler proposed) to replace the broken delete_key with a new delete_subkey which is simpler to implement and does not have the quirk to invalidate the current key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This necessitates a change in the documentation as well, which is why I avoided it initially. If we're certain we prefer it, I can make that change. Let me know :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, if you have done a delete_key that actually works I'm fine with keeping it.

@sverker
Copy link
Contributor

sverker commented Aug 12, 2021

@reganheath I would prefer if you could rearrange the commits with one for each issue, value and delete_key.

Also you should describe the actual fix in the commit headline, like "Fix win32reg:value/2 for default value". If referring the github issue or pull request do that with GH-5027 and PR-5038.

If you want, you could also rebase on maint ("git rebase --onto maint master") to get these fixes into OTP-24.1.

@sverker
Copy link
Contributor

sverker commented Aug 12, 2021

... and if so, also click Edit and change this PR to be based on maint.

@sverker sverker force-pushed the 5037_and_4702 branch 2 times, most recently from fa0c5e8 to db14aa8 Compare August 19, 2021 17:53
@sverker sverker changed the base branch from master to maint August 19, 2021 17:54
@sverker sverker added fix testing currently being tested, tag is used by OTP internal CI labels Aug 19, 2021
@sverker
Copy link
Contributor

sverker commented Aug 19, 2021

Rebased on maint and put into test.

@sverker
Copy link
Contributor

sverker commented Sep 1, 2021

Added win32reg:change_key(Reg, "\\hkcu") in the new tests to try fix failures with {error, eacces} on our test machines.

@reganheath
Copy link
Contributor Author

Sorry! I've been swamped with stuff recently.

The function win32reg:delete_key() did not work as documented.
It did not delete the current registry key and instead always
returned {error,einval} instead of ok.
@sverker sverker merged commit 5e73031 into erlang:maint Sep 8, 2021
@sverker
Copy link
Contributor

sverker commented Sep 8, 2021

Merged to maint for 24.1.
Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

win32reg:value/2 fails to get default value ('default' or "")
4 participants