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

Generating invalid UUIDs. #19

Open
cmeiklejohn opened this issue Mar 13, 2018 · 1 comment
Open

Generating invalid UUIDs. #19

cmeiklejohn opened this issue Mar 13, 2018 · 1 comment
Labels

Comments

@cmeiklejohn
Copy link

cmeiklejohn commented Mar 13, 2018

17:19:00.019 [info] Application lager started on node nonode@nohost
17:19:00.020 [info] Distributed Erlang is not enabled, generating UUID.
17:19:00.022 [info] Generated UUID: <<158,154,190,66,38,226,17,232,155,216,0,0,0,0>>, converting to string.
17:19:00.022 [error] CRASH REPORT Process <0.1006.0> with 0 neighbours exited with reason: bad argument in uuid:to_string/1 line 238
17:19:00.023 [error] CRASH REPORT Process <0.1004.0> with 0 neighbours exited with reason: {{error,{badarg,[{uuid,to_string,1,[{file,"/tmp/exlam/deps/uuid/src/uuid.erl"},{line,238}]},

This is Amazon Linux.

Now, when I generate identifiers locally, with the same version of Erlang, I'm getting 16 byte identifiers. But, when I run it here, as you can see from the binary above, it's only 14 bytes. This is causing the uuid:to_string method to throw, because it doesn't match at line 238. Any thoughts on why this would happen on a particular variant of Linux?

I'm using uuid4().

@avtobiff
Copy link
Owner

Sorry for not having time to look into this until now.

What environment is used?
(erlang-uuid, Errlang, OS versions; from source or package manager etc?)

The UUID you supplied is probably not v1 but v4. Padding to correct length
yields UUIDv1.

1> uuid:version(<<158,154,190,66,38,226,17,232,155,216,0,0,0,0>>).    
** exception error: bad argument
     in function  uuid:version/1 (src/uuid.erl, line 348)
2> uuid:version(<<158,154,190,66,38,226,17,232,155,216,0,0,0,0,0,0>>).
1

I suspect that the UUIDv1 somehow use a MAC address that are only zeroes
and this does not end up in a 48 bit wide binary but less.

Another suggestion is that this problem arises due to Erlang Time API changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants