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

uuid_create(UUID_TYPE_TIME) seems broken on 32-bit #206

Closed
guilliamxavier opened this issue Nov 29, 2019 · 6 comments · Fixed by #210
Closed

uuid_create(UUID_TYPE_TIME) seems broken on 32-bit #206

guilliamxavier opened this issue Nov 29, 2019 · 6 comments · Fixed by #210

Comments

@guilliamxavier
Copy link
Contributor

Run var_dump(uuid_create(UUID_TYPE_TIME)); several times with a few seconds/minutes delay between each call, here are some sample results:

  • on a 64-bit system:

    string(36) "3d18e40c-129d-11ea-94e6-61a012af7e36"
    string(36) "7dbf2f3e-129d-11ea-afb1-efd2f815ab0c"
    string(36) "95dd40d8-129d-11ea-be2a-931c452fa10d"
    string(36) "d58d1e1a-129d-11ea-93b0-9774d3d2232c"
    string(36) "007bc6c6-129e-11ea-bb10-e1b619b491ac"
    
  • on a 32-bit system:

    string(36) "3d710800-0000-1000-bc7d-81c9756e8182"
    string(36) "7de39b90-0000-1000-a067-8b759a2618f5"
    string(40) "95fa8cb0-ffff-ffffffff-91cb-b372558c0d82"
    string(40) "d5a82800-ffff-ffffffff-aac8-611f2a0e136d"
    string(36) "00c2eb80-0000-1000-9410-6b0dafe79f58"
    

    => the middle parts exhibit a problem

@stof
Copy link
Member

stof commented Nov 29, 2019

@lyrixx can you take a look at this ?

@stof
Copy link
Member

stof commented Nov 29, 2019

hmm, I see something weird here. The polyfill is expected to throw a RuntimeException when trying to generate a time-based uuid on a 32-bits PHP, saying it is unsupported. Are you actually using the polyfill, or do you have the uuid extension enabled ?

@guilliamxavier
Copy link
Contributor Author

@stof I don't have the uuid extension, I am using the polyfill. On a 32-bits PHP it throws a RuntimeException when calling uuid_time(), but not for uuid_create(UUID_TYPE_TIME) (which thus returns broken values). For information, here are my results for var_dump(uuid_time('3d18e40c-129d-11ea-94e6-61a012af7e36'));:

  • on a 64-bits PHP: int(1575027713)
  • on a 32-bits PHP: RuntimeException "UUID time generation is not supported on 32-bit systems. Use the uuid extension instead."

@guilliamxavier guilliamxavier changed the title uuid_create(UUID_TYPE_TIME) seems broken on 32-bit systems uuid_create(UUID_TYPE_TIME) seems broken on 32-bit Nov 29, 2019
@stof
Copy link
Member

stof commented Nov 29, 2019

it looks like the code for uuid_generate_time (the internal implementation of uuid_create(UUID_TYPE_TIME) is not compatible with 32-bits runtime either, but does not check for it.

@lyrixx
Copy link
Member

lyrixx commented Nov 29, 2019

@guilliamxavier It looks like I forgot this code path. Would you mind submitting a PR? If you can't or don't want to, no issue! Just tell me and I will do

@guilliamxavier
Copy link
Contributor Author

@lyrixx In #210 I just copied the check of uuid_time into uuid_generate_time, feel free to review/improve

nicolas-grekas added a commit that referenced this issue Nov 30, 2019
…vier)

This PR was merged into the 1.13-dev branch.

Discussion
----------

Check for 32-bit PHP in uuid_generate_time() too

Closes #206

Commits
-------

4306009 Check for 32-bit PHP in uuid_generate_time() too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants