Issue4607
Created on 2008-12-09 10:13 by mortenab, last changed 2009-01-10 20:55 by facundobatista.
|
msg77401 - (view) |
Author: Morten Bentsen (mortenab) |
Date: 2008-12-09 10:13 |
|
The uuid module uses a single global buffer for storing random values
obtained from the system. This can (and does) cause non-uniqueness of
generated id's when using the uuid4 function in a multithreaded program.
The following snippet shows the problem - _buffer is the global buffer:
# When the system provides a version-4 UUID generator, use it.
if _uuid_generate_random:
_uuid_generate_random(_buffer)
return UUID(bytes=_buffer.raw)
|
|
msg77402 - (view) |
Author: STINNER Victor (haypo) |
Date: 2008-12-09 10:31 |
|
It looks like the bug is already fixed in Python trunk:
def uuid4():
"""Generate a random UUID."""
# When the system provides a version-4 UUID generator, use it.
if _uuid_generate_random:
_buffer = ctypes.create_string_buffer(16)
_uuid_generate_random(_buffer)
return UUID(bytes=_buffer.raw)
...
Changeset: r67318. The changeset was not related to this issue, but
#4363 (Make uuid module functions usable without ctypes).
|
|
msg79574 - (view) |
Author: Facundo Batista (facundobatista) |
Date: 2009-01-10 20:55 |
|
Yes, _buffer is not longer global.
Thanks for the report!
|
|
| Date |
User |
Action |
Args |
| 2009-01-10 20:55:11 | facundobatista | set | status: open -> closed resolution: out of date messages:
+ msg79574 nosy:
+ facundobatista |
| 2008-12-09 10:32:00 | haypo | set | nosy:
+ haypo messages:
+ msg77402 |
| 2008-12-09 10:13:32 | mortenab | create | |
|