<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Hello Aaron,<br>
<br>
I'm going to make a guess that you have run into this bug:<br>
<br>
<pre wrap=""><a class="moz-txt-link-freetext" href="http://trac.osgeo.org/proj/ticket/74">http://trac.osgeo.org/proj/ticket/74</a>
</pre>
<pre wrap="">If so, the fix is quite simple (from the ticket description):
</pre>
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:
<blockquote>
<p>
memcpy( cache_key, cache_key_new, sizeof(char*) * cache_count);
</p>
</blockquote>
<p>
but we are actually trying to copy the contents of cache_key into
cache_key_new so the code should be:
</p>
<blockquote>
<p>
memcpy( cache_key_new, cache_key, sizeof(char*) * cache_count);
</p>
</blockquote>
<pre wrap="">
</pre>
I hope this proves helpful.<br>
<br>
Best Regards,<br>
<br>
Erik<br>
<br>
<br>
On 10/28/2010 12:00, <a class="moz-txt-link-abbreviated" href="mailto:proj-request@lists.maptools.org">proj-request@lists.maptools.org</a> wrote:
<blockquote
cite="mid:mailman.3.1288285202.8825.proj@lists.maptools.org"
type="cite">
<pre wrap="">Send Proj mailing list submissions to
        <a class="moz-txt-link-abbreviated" href="mailto:proj@lists.maptools.org">proj@lists.maptools.org</a>
To subscribe or unsubscribe via the World Wide Web, visit
        <a class="moz-txt-link-freetext" href="http://lists.maptools.org/mailman/listinfo/proj">http://lists.maptools.org/mailman/listinfo/proj</a>
or, via email, send a message with subject or body 'help' to
        <a class="moz-txt-link-abbreviated" href="mailto:proj-request@lists.maptools.org">proj-request@lists.maptools.org</a>
You can reach the person managing the list at
        <a class="moz-txt-link-abbreviated" href="mailto:proj-owner@lists.maptools.org">proj-owner@lists.maptools.org</a>
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 <a class="moz-txt-link-rfc2396E" href="mailto:aaron@cartopac.com"><aaron@cartopac.com></a>
Subject: [Proj] EXCEPTION_ACCESS_VIOLATION (0xc0000005) after many
        successful calls to pj_init_plus
To: <a class="moz-txt-link-rfc2396E" href="mailto:proj@lists.maptools.org">"proj@lists.maptools.org"</a> <a class="moz-txt-link-rfc2396E" href="mailto:proj@lists.maptools.org"><proj@lists.maptools.org></a>
Message-ID:
        <a class="moz-txt-link-rfc2396E" href="mailto:90200BC582E4FF488816D357540C1D4D22A76C0845@VMBX103.ihostexchange.net"><90200BC582E4FF488816D357540C1D4D22A76C0845@VMBX103.ihostexchange.net></a>
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 <a class="moz-txt-link-rfc2396E" href="mailto:EMiller@dfg.ca.gov"><EMiller@dfg.ca.gov></a>
Subject: Re: [Proj] EXCEPTION_ACCESS_VIOLATION (0xc0000005) after
        manysuccessful calls to pj_init_plus
To: <a class="moz-txt-link-rfc2396E" href="mailto:proj@lists.maptools.org">"proj@lists.maptools.org"</a> <a class="moz-txt-link-rfc2396E" href="mailto:proj@lists.maptools.org"><proj@lists.maptools.org></a>
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:4CC854FE.95FD.00E4.0@dfg.ca.gov"><4CC854FE.95FD.00E4.0@dfg.ca.gov></a>
Content-Type: text/plain; charset="US-ASCII"
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">On 10/27/2010 at 4:20 PM, Aaron Friesen <a class="moz-txt-link-rfc2396E" href="mailto:aaron@cartopac.com"><aaron@cartopac.com></a> wrote:
</pre>
</blockquote>
</blockquote>
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap="">
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...
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Erik Jacobsen, Power Line Systems, Inc.
Email: <a class="moz-txt-link-abbreviated" href="mailto:jacobsen@powline.com">jacobsen@powline.com</a>
Phone: (608) 238-2171 x134
Fax: (608) 238-9241
Web: <a class="moz-txt-link-freetext" href="http://www.powline.com/">http://www.powline.com/</a>
</pre>
</body>
</html>