[Proj] PROJ.4 thread-safety issues detailed

Gerald Evenden gerald.evenden at verizon.net
Mon Feb 28 14:11:39 EST 2005

I think you may have a case relating to pj_rotdms; I will have to look 
into it.
But it may not be needed depending upon your application.  For example,
if outputting decimal degrees then one can simply use C library 
Pj_rtodms is there as a "courtesy" routine and is not employed 
by libproj4.

The static struct pj_err_list could and should be made const.  In the 
it can be treated that way.

Most, if not all, of the other material does not involve libproj4.

Again, the sole problem with libproj4 is pj_errno.

On Feb 28, 2005, at 1:20 PM, Patrick Mézard wrote:

> Hello,
> I have looked for static variables in PROJ.4 code and found the
> following potential problems :
> 1-rtodms.c:
> RES, RES60, CONV, format, do_long are non-const globals.
> 2- pj_strerrno.c:
> note is static in pj_strerrno.
> 3- pj_open_lib.c :
> pj_finder, path_count, search_path are non-const globals.
> 4- pj_init.c
> start is a non-const global.
> 5- Many globals in grid stuff. Not listed
> 6- Some globals in geodesic stuff. Not listed.
> 7- Many globals in projection approximation code. Not listed.
> My point of view :
> - Evidently, everything (related to globals) can be solved by using
> thread-local storage.
> - I do not use 1, 5, 6, 7 and I will not try to edit them. 1 can be
> changed easily by adding a format description structure to function
> calls.
> - 2 is like the problem with pj_errno, and I will solve it with
> thread-local storage. It is hard to code something else without using
> callbacks or allocating memory which would make the whole think much
> more complicated to use.
> - 3 is used in pj_init. I do not use this feature, and I will just
> disable the +init and default parameters options.
> - 4 is critical but easily corrected by changing start into a local
> variable and passing it to every other function. See the attached
> patch.
> Hope this helps.
> Patrick Mézard
> <patch-pj_init_c.txt>_______________________________________________
> Proj mailing list
> Proj at xserve.flids.com
> http://xserve.flids.com/mailman/listinfo/proj
Jerry and the low riders: Daisy Mae and Joshua.
"The whole religious complexion of the modern world is due to the
absence from Jerusalem of a lunatic asylum." Havelock Ellis, 1914

More information about the Proj mailing list