jconway / plr

PL/R - R Procedural Language for PostgreSQL
http://www.joeconway.com
90 stars 41 forks source link

crash on bogus return statement (?) #1

Closed merlinm closed 10 years ago

merlinm commented 11 years ago

Trying out pl/r for the very first time, I was able to elicit a crash :-). R function:

mpf2=# CREATE OR REPLACE FUNCTION REcho(float8[]) RETURNS SETOF float8 AS mpf2-# $$ mpf2$# return mpf2$# $$ LANGUAGE plr; CREATE FUNCTION Time: 16.000 ms mpf2=# mpf2=# mpf2=# select recho(array[1.0, 2.0]); server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed.

The server log gave: 2012-08-29 15:42:57 CDT [rms@mpf2]: ERROR: cannot cast type integer to double precision[] at character 12 2012-08-29 15:42:57 CDT [rms@mpf2]: STATEMENT: select 1324::_float8; Error: cannot coerce type 'special' to vector of type 'character' Error: use of NULL environment is defunct

* caught segfault * address (nil), cause 'memory not mapped' aborting ... 2012-08-29 15:49:46 CDT [@]: LOG: server process (PID 31168) was terminated by signal 11: Segmentation fault 2012-08-29 15:49:46 CDT [@]: LOG: terminating any other active server processes

jconway commented 11 years ago

Thanks for the report -- will fix with next update

jconway commented 10 years ago

Well, it took quite a while, but I finally got around to fixing this bug. Sorry for the wait but the latest commit should do the trick -- namely it throws an error because the sample R code is bogus.