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

very occasional failures with threads #20

Open
rjbs opened this issue Aug 1, 2015 · 1 comment
Open

very occasional failures with threads #20

rjbs opened this issue Aug 1, 2015 · 1 comment

Comments

@rjbs
Copy link
Collaborator

rjbs commented Aug 1, 2015

See, for example, http://matrix.cpantesters.org/?dist=Data-UUID-1.220;reports=1

originally reported by @andk as https://rt.cpan.org/Ticket/Display.html?id=85978

@macar-cm
Copy link

macar-cm commented Jun 21, 2017

I noticed that this module is not thread-safe. new() and create() in UUID.xs attempt to save and restore the process's umask:

      mask = umask(_DEFAULT_UMASK);
      if ((fd = fopen(UUID_NODEID_NV_STORE, "wb"))) {
         fwrite(&(RETVAL->nodeid), sizeof(uuid_node_t), 1, fd);
         fclose(fd);
      };
      umask(mask);

If two threads attempt to create UUIDs at the same time, the original umask will be lost.

Changing the process umask seems to have been introduced in Data-UUID-0.05 ; I'm not sure why the umask was being reset instead of just specifying a mode in fopen() because it looks like fopen()'s mode argument doesn't include permissions, just how you're going to use the file.

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

No branches or pull requests

2 participants