[PROJ] About PROJ.6: inconsistent error reporting

Even Rouault even.rouault at spatialys.com
Tue Apr 2 03:36:17 PDT 2019


On mardi 2 avril 2019 08:42:18 CEST Kristian Evers wrote:
> This is definitely something that needs to be dealt with. Good catch!
> 
> As far as I can tell the problem is that errors that occur in the new
> C++ code are handled as exceptions without setting the internal
> PROJ errno. Eventually the exceptions are dealt with by logging
> an error message to stderr. There are two solutions:
> 
> 1. Have proj_create() issue a generic errno when catching an 
> exception, or
> 
> 2. Set an appropriate PROJ errno when raising an exception
> in the ISO19111 C++ code.
> 
> The first is the simplest but may not be suitable for all situations.
> The seconds is probably the best way to handle this but the fix will
> Involve a lot more work.
> 
> Even, do you have an opinion on which of the above roads to follow.
> Or perhaps a better solution?

I don't like at all the PROJ errno mechanism. It is hard to maintain and use. 
It works only for very precise conditions, so very often, the existing error 
messages are not exactly the ones I'd like to emit (speaking here with my 
experience with solving all the divide-by-zero situations found by ossfuzz), 
so I wonder if I reuse one close enough or invent a new code.

So I used the proj logging mechanism, which is also used in a few other places 
of the code base (not that much admitedly, and apparently coupled with setting 
a errno)

I would be more in the mind of the 1) option. This should be applied to all C+
+ code wrapped by a C function in src/iso19111/c_api.cpp

For the issue of the error being reported to stderr, you can easily shut it 
off by installing your own error handler with proj_log_func()

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the PROJ mailing list