Re: Access violation from palloc, Visual Studio 2005, C-language function

From: "Kevin Flanagan" <kevin-f(at)linkprior(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'PostgreSQL-development'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Access violation from palloc, Visual Studio 2005, C-language function
Date: 2010-03-10 10:03:58
Message-ID: 00bd01cac039$0139e240$03ada6c0$@com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Forgot to include the call stack info, such as it is - screen shot attached.

Kevin.

-----Original Message-----
From: pgsql-hackers-owner(at)postgresql(dot)org
[mailto:pgsql-hackers-owner(at)postgresql(dot)org] On Behalf Of Kevin Flanagan
Sent: 10 March 2010 09:29
To: 'Tom Lane'
Cc: 'PostgreSQL-development'
Subject: Re: [HACKERS] Access violation from palloc, Visual Studio 2005,
C-language function

Well -

>>
Hard to tell without seeing the actual code and a stack trace, but I'd bet
that you haven't fully resolved the build process problems you mentioned
earlier.
<<

I've attached a zip of the (tiny) project, and a text file with the contents
of the module containing the C-language functions. The only difference from
sample code is that (as pointed out by Takahiro Itagaki in his post here of
8th March) the function implementations need decorating with
__declspec(dllexport). (I hope the attachments don't break mailing list
policy.)

>>
I'm thinking this may be a symptom of linkage failure, since palloc is
probably the first place in the above-described sequence where your DLL is
going to call back into the core backend.
<<

Hmm. But isn't palloc found in postgres.lib, which my DLL statically links
to? Or is that not the lib I'm supposed to link to? (found in c c:\Program
Files\PostgreSQL\8.4\lib) If I don't include it as an input to the linker, I
get "unresolved external symbol _MemoryContextAlloc referenced in function
_copytext" and other unresolved externals ...

>>
Another possibility is that you mistranscribed the example somehow.
Maybe you forgot the PG_FUNCTION_INFO_V1(copytext) macro?
<<

No, that's there.

>>
> Failing that, are there any other (creative?) ways to return strings
> from
a
> C-language function without using palloc?
If you can't make those examples work, you have fundamental problems you
need to fix, not find a "creative workaround".
<<

I certainly agree in principle, but when you have a deadline to meet,
sometimes you can be under great pressure to find a temporary workaround ...
with the emphasis on temporary.

Thanks in advance for any further leads

Kevin

--
Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment Content-Type Size
palloc.jpg image/jpeg 228.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2010-03-10 11:38:12 Re: Re: Hot Standby query cancellation and Streaming Replication integration
Previous Message Kevin Flanagan 2010-03-10 09:28:40 Re: Access violation from palloc, Visual Studio 2005, C-language function