Thread: BUG #3523: plpython crash
The following bug has been logged online: Bug reference: 3523 Logged by: Julian Email address: julan@internode.on.net PostgreSQL version: 8.2.4 Operating system: Linux Description: plpython crash Details: -- PostgreSQL 8.2.4 on x86_64-pc-linux-gnu, compiled by GCC x86_64-pc-linux-gnu-gcc (GCC) 4.1.2 (Gentoo 4.1.2) --see if this crashes for you. BEGIN; CREATE FUNCTION pyfunction(tuple record) RETURNS "void" LANGUAGE "plpythonu" AS $$ $$ ; CREATE FUNCTION mytrigger () RETURNS "trigger" LANGUAGE "plpgsql" AS $$ BEGIN PERFORM pyfunction(NEW); END; $$ ; CREATE TABLE mytable (mycol text) ; CREATE TRIGGER mytrigger AFTER INSERT ON mytable FOR EACH ROW EXECUTE PROCEDURE mytrigger(); INSERT INTO mytable SELECT 'test'; ROLLBACK; ---------------------BACKTRACE------------------------ LOG: database system was interrupted at 2007-08-09 03:17:53 EST LOG: checkpoint record is at 0/5471B260 LOG: redo record is at 0/5471B260; undo record is at 0/0; shutdown TRUE LOG: next transaction ID: 0/196948; next OID: 608885 LOG: next MultiXactId: 1; next MultiXactOffset: 0 LOG: database system was not properly shut down; automatic recovery in progress LOG: redo starts at 0/5471B2B0 LOG: unexpected pageaddr 0/51862000 in log file 0, segment 84, offset 8790016 LOG: redo done at 0/54861E68 LOG: database system is ready *** glibc detected *** postgres: test test2 [local] INSERT: double free or corruption (out): 0x00002b7d14e40a30 *** ======= Backtrace: ========= /lib/libc.so.6[0x2b7d14c74b1d] /lib/libc.so.6(__libc_free+0x76)[0x2b7d14c76146] /usr/lib64/postgresql/plpython.so[0x2b7d16f32870] /usr/lib64/postgresql/plpython.so[0x2b7d16f32a77] /usr/lib64/postgresql/plpython.so(plpython_call_handler+0xbd)[0x2b7d16f3416d ] postgres: test test2 [local] INSERT(ExecMakeFunctionResult+0xfd)[0x4ff0dd] postgres: test test2 [local] INSERT(ExecProject+0x1c1)[0x4fd971] postgres: test test2 [local] INSERT(ExecResult+0x63)[0x50d473] postgres: test test2 [local] INSERT(ExecProcNode+0xc6)[0x4fd176] postgres: test test2 [local] INSERT(ExecutorRun+0x10a)[0x4fc47a] postgres: test test2 [local] INSERT[0x5130cb] postgres: test test2 [local] INSERT(SPI_execute_plan+0xad)[0x51332d] /usr/lib64/postgresql/plpgsql.so[0x2b7d16e1c310] /usr/lib64/postgresql/plpgsql.so[0x2b7d16e1ee43] /usr/lib64/postgresql/plpgsql.so[0x2b7d16e1e48a] /usr/lib64/postgresql/plpgsql.so(plpgsql_exec_trigger+0x358)[0x2b7d16e20448] /usr/lib64/postgresql/plpgsql.so(plpgsql_call_handler+0x152)[0x2b7d16e17c92] postgres: test test2 [local] INSERT[0x4e7b28] postgres: test test2 [local] INSERT[0x4e91c2] postgres: test test2 [local] INSERT(AfterTriggerEndQuery+0x55)[0x4e9545] postgres: test test2 [local] INSERT[0x582d29] postgres: test test2 [local] INSERT[0x582ea8] postgres: test test2 [local] INSERT(PortalRun+0x364)[0x583714] postgres: test test2 [local] INSERT[0x57f745] postgres: test test2 [local] INSERT(PostgresMain+0x1110)[0x580b70] postgres: test test2 [local] INSERT[0x55a3e7] postgres: test test2 [local] INSERT(PostmasterMain+0x6c1)[0x55afa1] postgres: test test2 [local] INSERT(main+0x183)[0x51c993] /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7d14c27374] postgres: test test2 [local] INSERT[0x43e6c9] ======= Memory map: ======== 00400000-00701000 r-xp 00000000 08:19 10261 /usr/bin/postgres 00800000-0080c000 rw-p 00300000 08:19 10261 /usr/bin/postgres 0080c000-009fb000 rw-p 0080c000 00:00 0 [heap] 2b7d1411a000-2b7d14135000 r-xp 00000000 08:19 948791 /lib64/ld-2.5.so 2b7d14135000-2b7d14157000 rw-p 2b7d14135000 00:00 0 2b7d14163000-2b7d141e7000 rw-p 2b7d14163000 00:00 0 2b7d14235000-2b7d14236000 r--p 0001b000 08:19 948791 /lib64/ld-2.5.so 2b7d14236000-2b7d14237000 rw-p 0001c000 08:19 948791 /lib64/ld-2.5.so 2b7d14237000-2b7d1423f000 r-xp 00000000 08:19 571744 /lib64/libpam.so.0.78 2b7d1423f000-2b7d1433e000 ---p 00008000 08:19 571744 /lib64/libpam.so.0.78 2b7d1433e000-2b7d1433f000 rw-p 00007000 08:19 571744 /lib64/libpam.so.0.78 2b7d1433f000-2b7d1437f000 r-xp 00000000 08:19 238686 /usr/lib64/libssl.so.0.9.8 2b7d1437f000-2b7d1447f000 ---p 00040000 08:19 238686 /usr/lib64/libssl.so.0.9.8 2b7d1447f000-2b7d14485000 rw-p 00040000 08:19 238686 /usr/lib64/libssl.so.0.9.8 2b7d14485000-2b7d145d0000 r-xp 00000000 08:19 249759 /usr/lib64/libcrypto.so.0.9.8 2b7d145d0000-2b7d146cf000 ---p 0014b000 08:19 249759 /usr/lib64/libcrypto.so.0.9.8 2b7d146cf000-2b7d146f2000 rw-p 0014a000 08:19 249759 /usr/lib64/libcrypto.so.0.9.8 2b7d146f2000-2b7d146f7000 rw-p 2b7d146f2000 00:00 0 2b7d146f7000-2b7d14778000 r-xp 00000000 08:19 398203 /usr/lib64/libkrb5.so.3.2 2b7d14778000-2b7d14878000 ---p 00081000 08:19 398203 /usr/lib64/libkrb5.so.3.2 2b7d14878000-2b7d1487c000 rw-p 00081000 08:19 398203 /usr/lib64/libkrb5.so.3.2 2b7d1487c000-2b7d14881000 r-xp 00000000 08:19 948786 /lib64/libcrypt-2.5.so 2b7d14881000-2b7d14980000 ---p 00005000 08:19 948786 /lib64/libcrypt-2.5.so 2b7d14980000-2b7d14982000 rw-p 00004000 08:19 948786 /lib64/libcrypt-2.5.so 2b7d14982000-2b7d149b0000 rw-p 2b7d14982000 00:00 0 2b7d149b0000-2b7d149b2000 r-xp 00000000 08:19 948775 /lib64/libdl-2.5.so 2b7d149b2000-2b7d14ab2000 ---p 00002000 08:19 948775 /lib64/libdl-2.5.so 2b7d14ab2000-2b7d14ab4000 rw-p 00002000 08:19 948775 /lib64/libdl-2.5.so 2b7d14ab4000-2b7d14ab5000 rw-p 2b7d14ab4000 00:00 0 2b7d14ab5000-2b7d14b09000 r-xp 00000000 08:19 948796 /lib64/libm-2.5.so 2b7d14b09000-2b7d14c08000 ---p 00054000 08:19 948796 /lib64/libm-2.5.so 2b7d14c08000-2b7d14c0a000 rw-p 00053000 08:19 948796 /lib64/libm-2.5.so 2b7d14c0a000-2b7d14d3c000 r-xp 00000000 08:19 948797 /lib64/libc-2.5.so 2b7d14d3c000-2b7d14e3b000 ---p 00132000 08:19 948797 /lib64/libc-2.5.so 2b7d14e3b000-2b7d14e3e000 r--p 00131000 08:19 948797 /lib64/libc-2.5.so 2b7d14e3e000-2b7d14e40000 rw-p 00134000 08:19 948797 /lib64/libc-2.5.so 2b7d14e40000-2b7d14e45000 rw-p 2b7d14e40000 00:00 0 2b7d14e45000-2b7d14e47000 r-xp 00000000 08:19 571700 /lib64/libcom_err.so.2.1 2b7d14e47000-2b7d14f46000 ---p 00002000 08:19 571700 /lib64/libcom_err.so.2.1 2b7d14f46000-2b7d14f47000 rw-p 00001000 08:19 571700 /lib64/libcom_err.so.2.1 2b7d14f47000-2b7d14f48000 rw-p 2b7d14f47000 00:00 0 2b7d14f48000-2b7d14f6b000 r-xp 00000000 08:19 397952 /usr/lib64/libk5crypto.so.3.0 2b7d14f6b000-2b7d1506a000 ---p 00023000 08:19 397952 /usr/lib64/libk5crypto.so.3.0 2b7d1506a000-2b7d1506c000 rw-p 00022000 08:19 397952 /usr/lib64/libk5crypto.so.3.0 2b7d1506c000-2b7d15073000 r-xp 00000000 08:19 398153 /usr/lib64/libkrb5support.so.0.1 2b7d15073000-2b7d15172000 ---p 00007000 08:19 398153 /usr/lib64/libkrb5support.so.0.1 2b7d15172000-2b7d15173000 rw-p 00006000 08:19 398153 /usr/lib64/libkrb5support.so.0.1 2b7d15173000-2b7d15183000 r-xp 00000000 08:19 948794 /lib64/libresolv-2.5.so 2b7d15183000-2b7d15282000 ---p 00010000 08:19 948794 /lib64/libresolv-2.5.so 2b7d15282000-2b7d15284000 rw-p 0000f000 08:19 948794 /lib64/libresolv-2.5.so 2b7d15284000-2b7d15288000 rw-p 2b7d15284000 00:00 0 2b7d15288000-2b7d1528f000 r-xp 00000000 08:19 948778 /lib64/libnss_compat-2.5.so 2b7d1528f000-2b7d1538e000 ---p 00007000 08:19 948778 /lib64/libnss_compat-2.5.so 2b7d1538e000-2b7d15390000 rw-p 00006000 08:19 948778 /lib64/libnss_compat-2.5.so 2b7d15390000-2b7d153a3000 r-xp 00000000 08:19 948789 /lib64/libnsl-2.5.so 2b7d153a3000-2b7d154a2000 ---p 00013000 08:19 948789 /lib64/libnsl-2.5.so 2b7d154a2000-2b7d154a4000 rw-p 00012000 08:19 948789 /lib64/libnsl-2.5.so 2b7d154a4000-2b7d154a6000 rw-p 2b7d154a4000 00:00 0 2b7d154a6000-2b7d154af000 r-xp 00000000 08:19 948785 /lib64/libnss_nis-2.5.so 2b7d154af000-2b7d155ae000 ---p 00009000 08:19 948785 /lib64/libnss_nis-2.5.so 2b7d155ae000-2b7d155b0000 rw-p 00008000 08:19 948785 /lib64/libnss_nis-2.5.so 2b7d155b0000-2b7d155ba000 r-xp 00000000 08:19 948799 /lib64/libnss_files-2.5.so 2b7d155ba000-2b7d156b9000 ---p 0000a000 08:19 948799 /lib64/libnss_files-2.5.so 2b7d156b9000-2b7d156bb000 rw-p 00009000 08:19 948799 /lib64/libnss_files-2.5.so 2b7d156bb000-2b7d16e0b000 rw-s 00000000 00:08 34897921 /SYSV0052e2c1 (deleted) 2b7d16e0b000-2b7d16e2b000 r-xp 00000000 08:19 49046 /usr/lib64/postgresql/plpgsql.so 2b7d16e2b000-2b7d16f2a000 ---p 00020000 08:19 49046 /usr/lib64/postgresql/plpgsql.so 2b7d16f2a000-2b7d16f2c000 rw-p 0001f000 08:19 49046 /usr/lib64/postgresql/plpgsql.so 2b7d16f2c000-2b7d16f38000 r-xp 00000000 08:19 49050 /usr/lib64/postgresql/plpython.so 2b7d16f38000-2b7d17037000 ---p 0000c000 08:19 49050 /usr/lib64/postgresql/plpython.so 2b7d17037000-2b7d17038000 rw-p 0000b000 08:19 49050 /usr/lib64/postgresql/plpython.so 2b7d17038000-2b7d1712d000 r-xp 00000000 08:19 792544 /usr/lib64/libpython2.4.so.1.0 2b7d1712d000-2b7d1722d000 ---p 000f5000 08:19 792544 /usr/lib64/libpython2.4.so.1.0 2b7d1722d000-2b7d1725b000 rw-p 000f5000 08:19 792544 /usr/lib64/libpython2.4.so.1.0 2b7d1725b000-2b7d17262000 rw-p 2b7d1725b000 00:00 0 2b7d1728f000-2b7d172a4000 r-xp 00000000 08:19 948774 /lib64/libpthread-2.5.so 2b7d172a4000-2b7d173a3000 ---p 00015000 08:19 948774 /lib64/libpthread-2.5.so 2b7d173a3000-2b7d173a4000 r--p 00014000 08:19 948774 /lib64/libpthread-2.5.so 2b7d173a4000-2b7d173a5000 rw-p 00015000 08:19 948774 /lib64/libpthread-2.5.so 2b7d173a5000-2b7d173a9000 rw-p 2b7d173a5000 00:00 0 2b7d173a9000-2b7d173ab000 r-xp 00000000 08:19 948790 /lib64/libutil-2.5.so 2b7d173ab000-2b7d174aa000 ---p 00002000 08:19 948790 /lib64/libutil-2.5.so 2b7d174aa000-2b7d174ac000 rw-p 00001000 08:19 948790 /lib64/libutil-2.5.so 2b7d174ac000-2b7d174ed000 rw-p 2b7d174ac000 00:00 0 2b7d174ee000-2b7d17560000 rw-p 2b7d174ee000 00:00 0 2b7d1758d000-2b7d17599000 r-xp 00000000 08:19 822805 /lib64/libgcc_s.so.1 2b7d17599000-2b7d17699000 ---p 0000c000 08:19 822805 /lib64/libgcc_s.so.1 2b7d17699000-2b7d1769a000 rw-p 0000c000 08:19 822805 /lib64/libgcc_s.so.1 2b7d18000000-2b7d18021000 rw-p 2b7d18000000 00:00 0 2b7d18021000-2b7d1c000000 ---p 2b7d18021000 00:00 0 7fff96978000-7fff96990000 rw-p 7fff96978000 00:00 0 [stack]
"Julian" <julan@internode.on.net> writes: > --see if this crashes for you. Yup. I think this'll fix it: Index: plpython.c =================================================================== RCS file: /cvsroot/pgsql/src/pl/plpython/plpython.c,v retrieving revision 1.90 diff -c -r1.90 plpython.c *** plpython.c 21 Nov 2006 21:51:05 -0000 1.90 --- plpython.c 10 Aug 2007 02:01:04 -0000 *************** *** 1237,1242 **** --- 1237,1243 ---- "proargnames must have the same number of elements " "as the function has arguments"); proc->argnames = (char **) PLy_malloc(sizeof(char *) * proc->nargs); + memset(proc->argnames, 0, sizeof(char *) * proc->nargs); } } for (i = 0; i < fcinfo->nargs; i++) regards, tom lane