[Proj] [PROJ] Re: EXCEPTION_ACCESS_VIOLATION (0xc0000005) after many successful, calls to pj_init_plus (Aaron Friesen)

Erik Jacobsen jacobsen at powline.com
Thu Oct 28 14:48:58 EST 2010


Hello Aaron,

I'm going to make a guess that you have run into this bug:

http://trac.osgeo.org/proj/ticket/74


If so, the fix is quite simple (from the ticket description):

On the 16th unique entry into the insert cache, it will need to be 
resized by pj_insert_cache() which has the source and destination 
arguments to memcpy reversed on line 157 of pj_initcache.c in the 
current trunk. This problem also exists in 4.7.0 where I found it during 
internal testing. The code is:

    memcpy( cache_key, cache_key_new, sizeof(char*) * cache_count);

but we are actually trying to copy the contents of cache_key into 
cache_key_new so the code should be:

    memcpy( cache_key_new, cache_key, sizeof(char*) * cache_count);

I hope this proves helpful.

Best Regards,

Erik


On 10/28/2010 12:00, proj-request at lists.maptools.org wrote:
> Send Proj mailing list submissions to
> 	proj at lists.maptools.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.maptools.org/mailman/listinfo/proj
> or, via email, send a message with subject or body 'help' to
> 	proj-request at lists.maptools.org
>
> You can reach the person managing the list at
> 	proj-owner at lists.maptools.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Proj digest..."
>
>
> Today's Topics:
>
>     1. EXCEPTION_ACCESS_VIOLATION (0xc0000005) after many successful
>        calls to pj_init_plus (Aaron Friesen)
>     2. Re: EXCEPTION_ACCESS_VIOLATION (0xc0000005) after
>        manysuccessful calls to pj_init_plus (Eric Miller)
>     3. truble to translate coordinates from WGS84 to EPSG:31287
>        (Markus Hetzmannseder)
>     4. Re: truble to translate coordinates from WGS84 to EPSG:31287
>        (Jean-Claude Repetto)
>     5. Re: truble to translate coordinates from WGS84 to EPSG:31287
>        (Markus Hetzmannseder)
>     6. Re: truble to translate coordinates from WGS84 to EPSG:31287
>        (Paul Kelly)
>     7. Re: truble to translate coordinates from WGS84 to EPSG:31287
>        (Markus Hetzmannseder)
>     8. Re: truble to translate coordinates from WGS84 to EPSG:31287
>        (Jean-Claude Repetto)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 27 Oct 2010 19:20:46 -0400
> From: Aaron Friesen<aaron at cartopac.com>
> Subject: [Proj] EXCEPTION_ACCESS_VIOLATION (0xc0000005) after many
> 	successful calls to pj_init_plus
> To: "proj at lists.maptools.org"<proj at lists.maptools.org>
> Message-ID:
> 	<90200BC582E4FF488816D357540C1D4D22A76C0845 at VMBX103.ihostexchange.net>
> Content-Type: text/plain; charset="us-ascii"
>
> Everyone,
>
> I have an application that runs as a web service.  It
> runs for a while, then any call to pj_init_plus with
> the same string that has been successfully running
> up to that point eventually results in an access
> violation during the pj_init_plus call.
>
> Restarting the service clears up the problem for a
> while, but once it hits, proj seems to be in a
> problem state.
>
> I believe I'm running 4.6.1.
>
> Are there any known problems like this?
>
> Does anyone see a problem with how I am calling proj?
>
> My sanitized code looks like (VS2005, c++):
>
> HRESULT Xform(int numXY, double* x, double* y, int numZ, double* z, char* src, char* dst)
> {
> 	if (numXY<= 0)
> 		return S_FALSE;
>
> 	if (!x || !y || (numZ>  0&&  !z))
> 		return E_INVALIDARG;
>
> 	HRESULT hr = S_OK;
> 	projPJ srcPJ = NULL;
> 	projPJ dstPJ = NULL;
>
> 	try
> 	{
> 		if (numZ == 0)
> 			z = NULL;
>
> 		if (!xformSpec.proj4CfsDefn || wcslen(xformSpec.proj4CfsDefn) == 0)
> 			throw E_INVALIDARG;
>
> 		srcPJ = pj_init_plus((char*)src);
> 		if (!srcPJ)
> 			throw E_PROJ_BAD_SRC_DEFN;
>
> 		dstPJ = pj_init_plus((char*)dst);
> 		if (!dstPJ)
> 			throw E_PROJ_BAD_DST_DEFN;
>
> 		int projResult = pj_transform(srcPJ, dstPJ, numXY, 1, x, y, z);
> 		if (projResult != 0)
> 			throw E_PROJ_FAILED;
> 	}
> 	catch(HRESULT thrown) { hr = thrown; }
> 	catch(...) { hr = E_UNEXPECTED; }
>
> 	if (srcPJ)
> 		pj_free(srcPJ);
> 	if (dstPJ)
> 		pj_free(dstPJ);
>
> 	return (FAILED(hr) ? hr : S_OK);
> }
>
>
> Thanks,
>
> Aaron
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 27 Oct 2010 16:36:14 -0700
> From: Eric Miller<EMiller at dfg.ca.gov>
> Subject: Re: [Proj] EXCEPTION_ACCESS_VIOLATION (0xc0000005) after
> 	manysuccessful calls to pj_init_plus
> To: "proj at lists.maptools.org"<proj at lists.maptools.org>
> Message-ID:<4CC854FE.95FD.00E4.0 at dfg.ca.gov>
> Content-Type: text/plain; charset="US-ASCII"
>
>>>> On 10/27/2010 at 4:20 PM, Aaron Friesen<aaron at cartopac.com>  wrote:
>> Everyone,
>>
>> I have an application that runs as a web service.  It
>> runs for a while, then any call to pj_init_plus with
>> the same string that has been successfully running
>> up to that point eventually results in an access
>> violation during the pj_init_plus call.
>>
>> Restarting the service clears up the problem for a
>> while, but once it hits, proj seems to be in a
>> problem state.
> PROJ.4 hasn't historically been thread safe.  That causes problems when trying to use it in a server/service context.  One of the trouble areas has been the handling of datum grid files.  Another is the global error code.  It may be that version 4.7 has improved that situation.  I gave up trying to use it in a web service years ago...

-- 
Erik Jacobsen, Power Line Systems, Inc.
Email: jacobsen at powline.com
Phone: (608) 238-2171 x134
Fax:   (608) 238-9241
Web:   http://www.powline.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20101028/96ee5296/attachment.htm 


More information about the Proj mailing list