View Issue Details

IDProjectCategoryView StatusLast Update
0031555FPCRTLpublic2017-03-17 09:00
ReporterPhilAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx64OSLinuxOS Version16.04
Product Version3.0.0Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0031555: CreateGUID fails regularly when multiprocessing
DescriptionCreateGuid fails regularly when used in a multiprocessing context.

The culprit is in rtl/linux/suuid.inc's CreateKernelGUID:

  fd:=FileOpen(KernelUUID,fmOpenRead);

If CreateGuid is called when another process has /proc/sys/kernel/random/uuid open, CreateKernelGUID's FileOpen fails, causing it to fall back on GetRandomBytes, which often produces duplicate GUIDs.

Solution: Open file in shared, rather than exclusive, mode:

  fd:=FileOpen(KernelUUID,fmOpenRead or fmShareDenyWrite);

Fix in GetURandomBytes too - same problem attempting to open /dev/urandom.

Needs to be fixed in rtl/bsd/suuid.inc.



TagsNo tags attached.
Fixed in Revision35611
FPCOldBugId
FPCTarget
Attached Files

Activities

Michael Van Canneyt

2017-03-17 09:00

administrator   ~0098956

Used fmShareDenyNone, it's a special device file anyway.
I also fixed the logic: if kernelguid fails, GetURandomBytes must be called, instead of GetRandomBytes.

Thanks for reporting!

Issue History

Date Modified Username Field Change
2017-03-17 01:30 Phil New Issue
2017-03-17 08:47 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-03-17 08:47 Michael Van Canneyt Status new => assigned
2017-03-17 09:00 Michael Van Canneyt Fixed in Revision => 35611
2017-03-17 09:00 Michael Van Canneyt Note Added: 0098956
2017-03-17 09:00 Michael Van Canneyt Status assigned => resolved
2017-03-17 09:00 Michael Van Canneyt Fixed in Version => 3.1.1
2017-03-17 09:00 Michael Van Canneyt Resolution open => fixed
2017-03-17 09:00 Michael Van Canneyt Target Version => 3.2.0