[postgis-devel] Need some help with memory contexts

Stephen Woodbridge woodbri at swoodbridge.com
Wed Apr 24 13:32:50 PDT 2013

I think I figured it out. You can't change to a fixed allocation block 
and add more to it. So I change to the parent context of the fixed block 
and that seems to have gotten beyond that crash. So now I need to do 
more testing.

Good news is things are progressing and I can get results out. Next is 
to move it back over to mingw and rebuild that with cassert and debug 
enabled in the server.


On 4/24/2013 3:47 PM, Stephen Woodbridge wrote:
> Hi Guys,
> I have finished recoding the address standardizer to use a standardizer
> cache mirroring the code for the projection cache.
> I've traced the current crash down to a memory context change where I
> need to pstrdup a few strings. There is nothing useful in the server logs.
> It is crashing on line 401 of
> http://pagc.svn.sourceforge.net/viewvc/pagc/branches/sew-refactor/postgresql/std_pg_hash.c?revision=350&view=markup
> My thesis on the memory context change is that the pstrdup strings
> should be allocated in the context of the cache entry so when the cache
> entry is deleted all strings will get freed with it. This also insures
> the the strings have the same lifetime as the cache entry.
> Anyway, any thoughts on why it is crashing on line 401?
> Is it valid to switch to this memory context?
> I has been very hard to find much of any doc on this stuff.
> Thanks,
>    -Steve
> Here is my trace using debug statements:
> woodbri at maps:~/work/pagc/branches/sew-refactor/postgresql$ psql -U
> postgres -h localhost test1 -f t.sql
> psql:t.sql:1: NOTICE:  Start standardize_address
> psql:t.sql:1: NOTICE:  calling RelationNameGetTupleDesc
> psql:t.sql:1: NOTICE:  calling GetStdUsingFCInfo(fcinfo, 'lex', 'gaz',
> 'rules')
> psql:t.sql:1: NOTICE:  GetStdUsingFCInfo: calling GetStdCache(fcinfo)
> psql:t.sql:1: NOTICE:  Enter: GetStdPortalCache
> psql:t.sql:1: NOTICE:  Allocating STDCache for portal with STD
> MemoryContext (0xb895d8a0)
> psql:t.sql:1: NOTICE:  GetStdUsingFCInfo: calling
> IsInStdCache(std_cache, lextab, gaztab, rultab)
> psql:t.sql:1: NOTICE:  Enter: IsInStdPortalCache
> psql:t.sql:1: NOTICE:  GetStdUsingFCInfo: calling
> AddToStdCache(std_cache, lextab, gaztab, rultab)
> psql:t.sql:1: NOTICE:  Enter: AddToStdPortalCache
> psql:t.sql:1: NOTICE:  Enter: CreateStd
> psql:t.sql:1: NOTICE:  start load_lex
> psql:t.sql:1: NOTICE:  Time to read 2938 lexicon records: 13.3 ms.
> psql:t.sql:1: NOTICE:  start load_lex
> psql:t.sql:1: NOTICE:  Time to read 1074 lexicon records: 5.5 ms.
> psql:t.sql:1: NOTICE:  start load_rules
> psql:t.sql:1: NOTICE:  Time to read 4368 rule records: 25.7 ms.
> psql:t.sql:1: NOTICE:  Adding item to STD cache ('lex', 'gaz', 'rules')
> index 0
> psql:t.sql:1: NOTICE:  Check if StdHash exists ((nil))
> psql:t.sql:1: NOTICE:  CreateStdHash: created StdHash (0xb89ae3c8)
> psql:t.sql:1: NOTICE:  Adding standardizer obj (0xb8836ca0) to hash
> table with MemoryContext key (0xb89999e8)
> psql:t.sql:1: NOTICE:  Enter: AddStdHashEntry(mcxt=0xb89999e8,
> std=0xb8836ca0)
> psql:t.sql:1: NOTICE:  AddStdHashEntry: he=0xb89aeda0, found=0
> psql:t.sql:1: NOTICE:  &he->context=0xb89aeda0
> psql:t.sql:1: NOTICE:  &he->std=0xb89aeda4
> psql:t.sql:1: NOTICE:  Leaving AddStdHashEntry
> psql:t.sql:1: NOTICE:  AddToStdPortalCache: changing memory context to
> 0xb89999e8
> psql:t.sql:1: NOTICE:    old_context= 0xb895d928
> psql:t.sql:1: SSL SYSCALL error: EOF detected
> psql:t.sql:1: connection to server was lost
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel

More information about the postgis-devel mailing list