After a fork(), uuid_generate_random() generates the same UUIDs in every child.
Originator: | yotam.gingold | ||
Number: | rdar://7944700 | Date Originated: | 05-May-2010 03:28 PM |
Status: | Open | Resolved: | |
Product: | Mac OS X | Product Version: | 10.6.3/10D578 |
Classification: | Security | Reproducible: | always |
05-May-2010 03:28 AM Yotam Gingold: 'multiprocessing_uuid.c' was successfully uploaded 05-May-2010 03:28 AM Yotam Gingold: Summary: After a fork(), uuid_generate_random() generates the same UUID sequence in every child. Steps to Reproduce: // g++ -o multiprocessing_uuid multiprocessing_uuid.c #include <stdio.h> #include <unistd.h> #include <uuid/uuid.h> int main( int argc, char* argv[] ) { for( int i = 0; i < 20; ++i ) { const int pid = fork(); if( pid == 0 ) { uuid_t uuid; uuid_generate_random( uuid ); char uuid_string[ 37 ]; uuid_unparse( uuid, uuid_string ); printf( "%s\n", uuid_string ); break; } } return 0; } Expected Results: 20 different UUIDs. Actual Results: 20 identical UUIDs. Regression: Notes:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Why would you expect this to work? It's well-known that the set of operations that are safe after fork() and before exec() is very small.