Search Postgresql Archives

backend crash following load command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We are getting a backend crash after issueing a load command.  It's
pretty easy to recreate -- so easy that I'm not sure that there is
something being overlooked.  This is on pg 8.2 roughly two weeks old.

Basic m.o. is:
1. create pic .so
2. load .so and call a function in it (from psql).
3. recompile .so with no changes to source
4. load again and crash.  note that merely touching the file and not
recompiling does not cause a crash...example stack trace:

Process 4808 attached - interrupt to quit
recv(8, "Q\0\0\0\35load \'/pgtest/pgfuncs\'\n;\0", 8192, 0) = 30
gettimeofday({1164652467, 63440}, NULL) = 0
write(2, "LOG:  statement: load \'/pgtest/p"..., 43) = 43
_llseek(3, 0, [16384], SEEK_CUR)        = 0
close(3)                                = 0
[snip]
_llseek(32, 0, [122880], SEEK_CUR)      = 0
close(32)                               = 0
_llseek(33, 0, [8192], SEEK_CUR)        = 0
close(33)                               = 0
_llseek(34, 0, [32768], SEEK_CUR)       = 0
close(34)                               = 0
stat64("/pgtest/pgfuncs", 0xbfec3820)   = -1 ENOENT (No such file or
directory)
stat64("/pgtest/pgfuncs.so", {st_mode=S_IFREG|0755, st_size=4490, ...}) = 0
stat64("/pgtest/pgfuncs.so", {st_mode=S_IFREG|0755, st_size=4490, ...}) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---


detailed steps to create the problem follow:

1. Create the C function
// pgfuncs.c
#include "postgres.h"
#include "fmgr.h"

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(addone);

Datum addone(PG_FUNCTION_ARGS)
{
 PG_RETURN_INT32(PG_GETARG_INT32(0) + 1);
}
// end pgfuncs.c


2. compile it
PG_SERVER_INC=/usr/local/pgsql/include/server
gcc -fpic -shared -I $PG_SERVER_INC -o /pgtest/pgfuncs.so pgfuncs.c


3. create the addone func (using a fresh psql session)
CREATE OR REPLACE FUNCTION addone(INTEGER) RETURNS INTEGER
 AS '/pgtest/pgfuncs', 'addone' LANGUAGE C STRICT;


4. Execute addone, which will load pgfuncs.so
funcy=# select addone(1);
addone
--------
     2
(1 row)


5. Try to reload the library (this works)
funcy=# LOAD '/pgtest/pgfuncs';
LOAD


6. Recomplie pgfuncs.so
Follow the same steps that are outlined in Step 2.


7. Issue a LOAD 'library' command
funcy=# LOAD '/pgtest/pgfuncs';
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.
!>

merlin


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux