Closed jjimenezshaw closed 4 years ago
I believe https://github.com/OSGeo/gdal/commit/75b6fafc46cef6b4130d7e39cbc136c98cb23e7c (and its backport to 3.1 branch for 3.1.1) effectively fixed the issue for threads. I couldn't reproduce it, whereas if assigning 0 to curpid instead of getpid() as before the fix, I could reproduce it. And your use case actually revealed what was wrong: we were using the PROJ nullptr default context, which isn't thread-safe. In e873aa2, I've pushed a change to make the code hopefully a bit more robust.
Expected behavior and actual behavior.
Opening many TIFF files in parallel sometimes produces a segmentation fault in
proj
code. I created a small piece of code that tries to replicate that behavior.Increase the number of threads if it does not triggers the segfault.
75b6faf from #2616 (currently in master, initializing
curpid
inOSRPJContextHolder
) is probably fixing (or hiding) the problem because what I am doing is a new thread, not afork
. However I think it still may happen when afork
is done. This code is tested in3.1.0
Setting the environment variable
PROJ_LIB
to findproj.db
does not help. Anyhow, the program just want to read the TIFF, and do not care about coordinates. I understand thatproj.db
is not needed inGDAL
if you do not use any CRS.Steps to reproduce the problem.
Sample code (no deletion is done, I know). "sample.tif" must be there, a normal TIFF file. (I usually read different files, but this makes the sample simpler)
Backtrace:
Now I compiled
proj
indebug
In my complex application, I got a similar (but not the same) backtrace:
or also this
Operating system
Ubuntu 18.04 64 bit
GDAL version and provenance
GDAL 3.1.0 compiled from source code. PROJ 7.0.1 compiled from source code.