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

os.getRandomBytes failing on windows #725

Closed
Yassim opened this issue Jan 28, 2018 · 3 comments
Closed

os.getRandomBytes failing on windows #725

Yassim opened this issue Jan 28, 2018 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Milestone

Comments

@Yassim
Copy link

Yassim commented Jan 28, 2018

There seem to be missing some test files form the std lib.
io_test.zig, rand_test.zig, test.zig - maybe others.

Rep steps.

  1. Download 0.1.1.f66ac9a5 from appveyor - and extract
  2. run 'zig test lib/zig/std/index.zig'
  3. Note missing file errors.

Using the replacing the contents of lib/zig/std with that from a dowload of master, looks to run as expected. (Fails for a different reason

Test 49/288 os.getRandomBytes...error: Unexpected
Unable to open debug info: TodoSupportCoffDebugInfo

But I'm guessing thats more expected.
)

@andrewrk
Copy link
Member

This is intentional. These test files are somewhat large, and only necessary for testing the standard library, not for using it. A release build of zig is not expected to be able to pass the test suite, only a source checkout is.

"Unable to open debug info: TodoSupportCoffDebugInfo" is #721

Test 49/288 os.getRandomBytes...error: Unexpected this is in fact a test failure, but it sounds like you copied files around and did not do a straightforward run of the tests from a clone of master branch. If you repeat the steps for testing from README.md and get a test failure, I'd like to know about it. I'd be surprised, since they all pass on appveyor as well as my windows laptop.

@Yassim
Copy link
Author

Yassim commented Jan 29, 2018

Ack.. Applogies for Necro threading..
The test that was failing (to produce the Todo...) was 'os.getRandomBytes' which might have been usful in my first post.

I'm on Windows 10, and on my system atleast, the call to CryptAcquireContextA fail if (and only if) it has never been called before with a specific name (null in this case is specific) and flag of CRYPT_NEWKEYSET (0x8).

Get Last error returns 0x‭80090016‬ (which is NTE_BAD_KEYSET).

If you have called it at least once with flags = CRYPT_NEWKEYSET, then your fine, untill you use a name it hasnt seen before.

Solution seems to be, call it with flags = 0, if that fails with NTE_BAD_KEYSET, then call it with flags = CRYPT_NEWKEYSET.

I did this, and all tests passed.
I can hopfuly submit a PR for this in a week or so.. (Sorry delay due to mundane constraints.)

@andrewrk
Copy link
Member

No worries! Thanks for reporting back.

@andrewrk andrewrk reopened this Jan 29, 2018
@andrewrk andrewrk changed the title Missing test files from appveyor artifact os.getRandomBytes failing on windows Jan 29, 2018
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior os-windows labels Jan 29, 2018
@andrewrk andrewrk added this to the 0.2.0 milestone Jan 29, 2018
@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Projects
None yet
Development

No branches or pull requests

2 participants