erlang-uuid icon indicating copy to clipboard operation
erlang-uuid copied to clipboard

uuid1() fails in Erlang 19.3 but not in Erlang 20

Open tommyjcarpenter opened this issue 7 years ago • 5 comments

The same line:

uuid:to_string(uuid:uuid1()))

Fails in Erlang 19.3, but works in 20. In 19.3 it bombs with the error:

Failure/Error: {error,badarg,
                    [{uuid,to_string,1,
                         [{file,
                              "/tmp/_build/default/lib/uuid/src/uuid.erl"},
                          {line,238}]},

However,

uuid:to_string(uuid:uuid4())

works in both. I'm not an expert in Erlang, HOWEVER my guess is it has something to do with os.timestamp here: https://github.com/avtobiff/erlang-uuid/blob/master/src/uuid.erl#L101 This is just a guess of where the problem is because I recall that Erlang changed the behavior of this at some point.

tommyjcarpenter avatar Feb 07 '18 13:02 tommyjcarpenter

this also fails again in erl 21

tommyjcarpenter avatar Nov 27 '18 19:11 tommyjcarpenter

Sorry for not having time looking into this until now.

Is this related to #19 ?

What environment is used? (OS, Erlang from source or package manager etc?)

avtobiff avatar Dec 10 '18 08:12 avtobiff

RE #19 , it could be (see below*), but my original hunch was that it was related to the Erlang timestamp changes, because UUID4 works fine, and UUID1 is the method that uses the timestamp.

This is running in the standard Erlang Docker release. This issue does not happen on my personal MAC*, but only happens when I use the more recent versions of Erlang in Docker which are Unix (alpine? Ubuntu?). Because of this the host OS is different, see here: https://hub.docker.com/_/erlang/)

tommyjcarpenter avatar Dec 10 '18 11:12 tommyjcarpenter

I've tried OTP 19, 20, and 21; and also tried the docker images for said releases and I can't reproduce the issue.

What version of erlang-uuid do you use? If you aren't using v0.5.2 can you try reproducing the issue with that?

What Docker network driver are you using? I.e. do you have a proper MAC address in the container?

avtobiff avatar Dec 13 '18 20:12 avtobiff

Right now I wasn't pinning a particular version, I have in my rebar.config:

{uuid, ".*",  {git, "https://github.com/avtobiff/erlang-uuid.git", {branch, "master"}}},

In Docker Erlang 19 this is blowing up with

  2) util_tests:get_platform_envs_and_config_test/0
     Failure/Error: {error,badarg,
                        [{uuid,to_string,1,
                             [{file,
                                  "/tmp/_build/default/lib/uuid/src/uuid.erl"},
                              {line,245}]},

The calling line is

uuid:to_string(uuid:uuid1()).

Note uuid 4 works fine, e.g.,

uuid:to_string(uuid:uuid4()).

has no problem. That's why I suspect it's related to the timezone changes?

EDIT: this fails for me on v0.5.2 as well.

tommyjcarpenter avatar Dec 23 '18 18:12 tommyjcarpenter