Opened 8 years ago
Closed 8 years ago
#6428 closed defect (fixed)
CPLGenerateTempFilename can generate non-unique filenames
Reported by: | olt | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 2.1.0 |
Component: | default | Version: | svn-trunk |
Severity: | normal | Keywords: | |
Cc: | olt |
Description
CPLGenerateTempFilename can return the same filename when it is called from multiple processes (not threads).
CPLGenerateTempFilename calls CPLGetPID to get a unique ID for the process. CPLGetPID calls pthread_self on POSIX systems, but the result is not required to be unique.
Citing http://man7.org/linux/man-pages/man3/pthread_self.3.html:
Thread identifiers should be considered opaque: any attempt to use a thread ID other than in pthreads calls is nonportable and can lead to unspecified results. Thread IDs are guaranteed to be unique only within a process.
I noticed this bug in practice when I called gdal_fillnodata.py in parallel from a script. (GDAL 1.11.3 on Mac OS X 10.10.5.) I'm getting errors like the following (not always, but often):
ERROR 4: `/var/folders/np/2fhk15fn5qq6fm4j9s3vt_6r0000gn/T/1903174400_0fill_y_work.tif' does not exist in the file system, and is not recognised as a supported dataset name.
Change History (1)
comment:1 by , 8 years ago
Milestone: | → 2.1.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
trunk r33817 "Add CPLGetCurrentProcessID() and use it in CPLGenerateTempFilename() to have system-wide unique filenames (#6428)"