Re: Issues with C++ exception handling in an FDW

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: "Soules, Craig" <craig(dot)soules(at)hp(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Issues with C++ exception handling in an FDW
Date: 2012-01-31 18:52:52
Message-ID: CAEYLb_WCA-mgRQxGZ3nJXf0jYiFGEmBG=6SwY0QpCk08t8krew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 30 January 2012 23:04, Soules, Craig <craig(dot)soules(at)hp(dot)com> wrote:
> When there are no errors everything works flawlessly, however, we noticed that even throwing an exception in the C++ layer was causing an immediate segmentation fault.  Even when encapsulated in a try { } catch(...) { } block.
>
> If anyone has seen anything like this, any pointers or suggestions would be much appreciated.  I have followed all of the recommendations in the PostgreSQL documentation, with no luck.  I am not overloading the _init() functions in either shared library (another potential source of errors I have read about).

I suggest that you generalise from the example of PLV8. The basic
problem is that the effect of longjmp()ing over an area of the stack
with a C++ non-POD type is undefined. I don't think you can even use
structs, as they have implicit destructors in C++.

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-01-31 18:56:09 Re: pgsql_fdw, FDW for PostgreSQL server
Previous Message Andrew Dunstan 2012-01-31 18:48:36 Re: JSON for PG 9.2