petdance/scratch — Issue #308: Segmentation fault when calling .finish on unopend postgres connection
Author: petdance
Created: 2011-11-14 05:55:36+00:00
State: open
Labels: bug, library, Pri-normal, Sev-medium

{{{
.HLL 'perl6'
.sub main :main
load_bytecode 'Pg.pir'
$P0 = new 'Pg'
$P1 = $P0.'connectdb'('username=fantasy password=values')
$I0 = $P1.'status'()
say $I0
$P1.'finish'()
.end
}}}

The fantasy connection parameters cause the connect to fail, and then calling the finish method results in hilarity:

{{{
(gdb) run foo.pir
Starting program: /nocrypt-home/moritz/source/rakudo/parrot_install/bin/parrot foo.pir
[Thread debugging using libthread_db enabled]
warning: Lowest section in /usr/lib/libicudata.so.36 is .hash at 0000000000000120
[New Thread 0x7fe533a146f0 (LWP 8529)]
12319936
*** glibc detected *** /nocrypt-home/moritz/source/rakudo/parrot_install/bin/parrot: free(): invalid pointer: 0x0000000000c54958 ***
======= Backtrace: =========
/lib/libc.so.6[0x7fe5315039a8]
/lib/libc.so.6(cfree+0x76)[0x7fe531505ab6]
/lib/libc.so.6(freeaddrinfo+0x28)[0x7fe531547f88]
/usr/lib/libpq.so[0x7fe530b119bd]
/usr/lib/libpq.so(PQfinish+0xe)[0x7fe530b11b3e]
/home/moritz/rakudo/parrot_install/lib/libparrot.so.2.5.0[0x7fe5334bbd48]
/home/moritz/rakudo/parrot_install/lib/libparrot.so.2.5.0[0x7fe5334f92c1]
/home/moritz/rakudo/parrot_install/lib/libparrot.so.2.5.0[0x7fe5334d5931]
/home/moritz/rakudo/parrot_install/lib/libparrot.so.2.5.0[0x7fe5334d4ead]
/home/moritz/rakudo/parrot_install/lib/libparrot.so.2.5.0[0x7fe5334ac45c]
/home/moritz/rakudo/parrot_install/lib/libparrot.so.2.5.0(Parrot_pcc_invoke_from_sig_object+0x101)[0x7fe5334a83a1]
/home/moritz/rakudo/parrot_install/lib/libparrot.so.2.5.0(Parrot_pcc_invoke_sub_from_c_args+0xeb)[0x7fe5334a849b]
/nocrypt-home/moritz/source/rakudo/parrot_install/bin/parrot[0x40185e]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7fe5314ae1a6]
/nocrypt-home/moritz/source/rakudo/parrot_install/bin/parrot[0x4011c9]
======= Memory map: ========
00400000-00409000 r-xp 00000000 08:07 10078770 /nocrypt-home/moritz/source/rakudo/parrot_install/bin/parrot
00609000-0060a000 rw-p 00009000 08:07 10078770 /nocrypt-home/moritz/source/rakudo/parrot_install/bin/parrot
00b25000-00c9d000 rw-p 00000000 00:00 0 [heap]
7fe528000000-7fe528021000 rw-p 00000000 00:00 0
7fe528021000-7fe52c000000 ---p 00000000 00:00 0
7fe52e654000-7fe52e6b9000 r-xp 00000000 08:01 398415 /usr/lib/libgcrypt.so.11.4.4
7fe52e6b9000-7fe52e8b8000 ---p 00065000 08:01 398415 /usr/lib/libgcrypt.so.11.4.4
7fe52e8b8000-7fe52e8bb000 rw-p 00064000 08:01 398415 /usr/lib/libgcrypt.so.11.4.4
7fe52e8bb000-7fe52e8ca000 r-xp 00000000 08:01 398445 /usr/lib/libtasn1.so.3.0.15
7fe52e8ca000-7fe52eaca000 ---p 0000f000 08:01 398445 /usr/lib/libtasn1.so.3.0.15
7fe52eaca000-7fe52eacb000 rw-p 0000f000 08:01 398445 /usr/lib/libtasn1.so.3.0.15
7fe52eacb000-7fe52eb72000 r-xp 00000000 08:01 402186 /usr/lib/libgnutls.so.26.4.6
7fe52eb72000-7fe52ed72000 ---p 000a7000 08:01 402186 /usr/lib/libgnutls.so.26.4.6
7fe52ed72000-7fe52ed7d000 rw-p 000a7000 08:01 402186 /usr/lib/libgnutls.so.26.4.6
7fe52ed7d000-7fe52ed96000 r-xp 00000000 08:01 397607 /usr/lib/libsasl2.so.2.0.22
7fe52ed96000-7fe52ef96000 ---p 00019000 08:01 397607 /usr/lib/libsasl2.so.2.0.22
7fe52ef96000-7fe52ef97000 rw-p 00019000 08:01 397607 /usr/lib/libsasl2.so.2.0.22
7fe52ef97000-7fe52efa5000 r-xp 00000000 08:01 398439 /usr/lib/liblber-2.4.so.2.1.0
7fe52efa5000-7fe52f1a5000 ---p 0000e000 08:01 398439 /usr/lib/liblber-2.4.so.2.1.0
7fe52f1a5000-7fe52f1a6000 rw-p 0000e000 08:01 398439 /usr/lib/liblber-2.4.so.2.1.0
7fe52f1a6000-7fe52f1b6000 r-xp 00000000 08:01 413433 /lib/libresolv-2.7.so
7fe52f1b6000-7fe52f3b6000 ---p 00010000 08:01 413433 /lib/libresolv-2.7.so
7fe52f3b6000-7fe52f3b8000 rw-p 00010000 08:01 413433 /lib/libresolv-2.7.so
7fe52f3b8000-7fe52f3ba000 rw-p 00000000 00:00 0
7fe52f3ba000-7fe52f3bc000 r-xp 00000000 08:01 413691 /lib/libkeyutils-1.2.so
7fe52f3bc000-7fe52f5bb000 ---p 00002000 08:01 413691 /lib/libkeyutils-1.2.so
7fe52f5bb000-7fe52f5bc000 rw-p 00001000 08:01 413691 /lib/libkeyutils-1.2.so
7fe52f5bc000-7fe52f5c3000 r-xp 00000000 08:01 396932 /usr/lib/libkrb5support.so.0.1
7fe52f5c3000-7fe52f7c3000 ---p 00007000 08:01 396932 /usr/lib/libkrb5support.so.0.1
7fe52f7c3000-7fe52f7c4000 rw-p 00007000 08:01 396932 /usr/lib/libkrb5support.so.0.1
7fe52f7c4000-7fe52f7e8000 r-xp 00000000 08:01 397242 /usr/lib/libk5crypto.so.3.1
7fe52f7e8000-7fe52f9e8000 ---p 00024000 08:01 397242 /usr/lib/libk5crypto.so.3.1
7fe52f9e8000-7fe52f9ea000 rw-p 00024000 08:01 397242 /usr/lib/libk5crypto.so.3.1
7fe52f9ea000-7fe52fa00000 r-xp 00000000 08:01 397696 /usr/lib/libz.so.1.2.3.3
7fe52fa00000-7fe52fc00000 ---p 00016000 08:01 397696 /usr/lib/libz.so.1.2.3.3
7fe52fc00000-7fe52fc01000 rw-p 00016000 08:01 397696 /usr/lib/libz.so.1.2.3.3
7fe52fc01000-7fe52fc46000 r-xp 00000000 08:01 402194 /usr/lib/libldap_r-2.4.so.2.1.0
7fe52fc46000-7fe52fe45000 ---p 00045000 08:01 402194 /usr/lib/libldap_r-2.4.so.2.1.0
7fe52fe45000-7fe52fe48000 rw-p 00044000 08:01 402194 /usr/lib/libldap_r-2.4.so.2.1.0
7fe52fe48000-7fe52fe4a000 rw-p 00000000 00:00 0
7fe52fe4a000-7fe52fe75000 r-xp 00000000 08:01 396916 /usr/lib/libgssapi_krb5.so.2.2
7fe52fe75000-7fe530074000 ---p 0002b000 08:01 396916 /usr/lib/libgssapi_krb5.so.2.2
7fe530074000-7fe530076000 rw-p 0002a000 08:01 396916 /usr/lib/libgssapi_krb5.so.2.2
7fe530076000-7fe530079000 r-xp 00000000 08:01 411320 /lib/libcom_err.so.2.1
7fe530079000-7fe530278000 ---p 00003000 08:01 411320 /lib/libcom_err.so.2.1
7fe530278000-7fe530279000 rw-p 00002000 08:01 411320 /li
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fe533a146f0 (LWP 8529)]
0x00007fe5314c1ed5 in raise () from /lib/libc.so.6
}}}

{{{
(gdb) bt
#0 0x00007fe5314c1ed5 in raise () from /lib/libc.so.6
#1 0x00007fe5314c33f3 in abort () from /lib/libc.so.6
#2 0x00007fe5314fe408 in ?? () from /lib/libc.so.6
#3 0x00007fe5315039a8 in ?? () from /lib/libc.so.6
#4 0x00007fe531505ab6 in free () from /lib/libc.so.6
#5 0x00007fe531547f88 in freeaddrinfo () from /lib/libc.so.6
#6 0x00007fe530b119bd in ?? () from /usr/lib/libpq.so
#7 0x00007fe530b11b3e in PQfinish () from /usr/lib/libpq.so
#8 0x00007fe5334bbd48 in pcf_v_p (interp=0xb25080, nci=, self_unused=)
at src/nci/extra_thunks.c:375
#9 0x00007fe5334f92c1 in Parrot_NCI_invoke (interp=0xb25080, _self=0xc69e00, next=0xc82650) at ./src/pmc/nci.pmc:379
#10 0x00007fe5334d5931 in runops_slow_core (interp=0xb25080, runcore_unused=, pc=0xc82640)
at src/runcore/cores.c:647
#11 0x00007fe5334d4ead in runops_int (interp=0xb25080, offset=0) at src/runcore/main.c:237
#12 0x00007fe5334ac45c in runops (interp=0xb25080, offs=) at src/call/ops.c:127
#13 0x00007fe5334a83a1 in Parrot_pcc_invoke_from_sig_object (interp=0xb25080, sub_obj=0xbb6520, call_object=)
at src/call/pcc.c:366
#14 0x00007fe5334a849b in Parrot_pcc_invoke_sub_from_c_args (interp=0xb25080, sub_obj=0xbb6520, sig=)
at src/call/pcc.c:87
#15 0x000000000040185e in main (argc=1, argv=0x7fffe5973048) at src/main.c:149
}}}

Originally http://trac.parrot.org/parrot/ticket/1695