On 27 October 2016 at 09:22, Chapman Flack <c...@anastigmatix.net> wrote:

> Hmm, IsUnderPostmaster is PGDLLIMPORTed but IsPostmasterEnvironment isn't,
> so I'm out of luck on Windows. Is there another way I can check?
>
>>> Do I detect I'm in a BGW by a non-null MyBgworkerEntry?
>>
>> Use IsBackgroundWorker, same place as above.
>
> Also not PGDLLIMPORTed. MyBgworkerEntry is, though. It does appear to be
> initialized to NULL. Can I get away with checking that, since I can't see
> IsBackgroundWorker?
>
> I now see what caused the reported crash. It was a parallel query that
> did not make any use of PL/Java functions, but the group leader had used
> them before so the library was loaded, so ParallelWorkerMain loaded it
> in the worker process, so _PG_init got called and was going to refer to
> stuff that wasn't set up yet, because the library loading comes pretty
> early in ParallelWorkerMain.
>
> I think I could easily fix that by having the library init code just bail
> right after defining the custom GUCs, if InitializingParallelWorker
> is true.
>
> Alas, InitializingParallelWorker isn't PGDLLIMPORTed either. This isn't
> my day. Is there a way I can successfully infer that on Windows?

Please submit a patch to make them all PGDLLIMPORT. They clearly
should be, for use in bgworkers.

I'd consider that a bugfix personally and hope it can be backpatched
to the stable branches. It's not going to break anything since nothing
external that runs on Windows can previously have been referring to
these symbols.

-- 
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


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

Reply via email to