Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 8D907B5DBC4 for ; Sun, 24 Jul 2011 18:12:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 91919-03 for ; Sun, 24 Jul 2011 21:12:29 +0000 (UTC) X-Greylist: delayed 00:05:01.371843 by SQLgrey-1.7.6 Received: from mail.cs.helsinki.fi (courier.cs.helsinki.fi [128.214.9.1]) by mail.postgresql.org (Postfix) with ESMTP id CECDCB5D8C5 for ; Sun, 24 Jul 2011 18:12:28 -0300 (ADT) Received: from roundcube.cs.helsinki.fi (svm-10.cs.helsinki.fi [128.214.11.79]) (AUTH: PLAIN noordsij, SSL: TLSv1/SSLv3,256bits,AES256-SHA) by mail.cs.helsinki.fi with esmtp; Mon, 25 Jul 2011 00:07:24 +0300 id 0008C631.4E2C898C.00000A59 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Date: Mon, 25 Jul 2011 00:06:46 +0300 From: noordsij To: Robert Haas Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6086: Segmentation fault In-Reply-To: References: <201106300732.p5U7W0Bj001711@wwwmaster.postgresql.org> Message-ID: X-Sender: noordsij@cs.helsinki.fi User-Agent: RoundCube Webmail/0.2.1 X-Mime-Autoconverted: from 8bit to 7bit by courier 0.53 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.093 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.193 X-Spam-Level: X-Archive-Number: 201107/168 X-Sequence-Number: 30780 > Any idea what query triggered this? Only up to which stored procedure (which itself contains multiple statements). However, in a new fresh FreeBSD environment (under virtualbox) I can trigger a similar (my guess is it is the same issue) segmentation fault reliably. Application is a Python web app, using psycopg2. It creates N worker threads, where each worker thread creates its own connection to postgresql. The threads then block on a global queue from which they read and process requests. That is, connections are not shared between threads, and all queries that are part of servicing a request are inside a single transaction bound to a single connection. Connections are re-used. (please assume this is implemented correctly on the client; a faulty client should not crash a server) If N=1, everything is OK. If N=3 (confirmed, but I suppose anything > 1) then the following happens for one particular testcase every single time: gdb `which postgres` /usr/local/pgsql/data/postgres.core GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "amd64-marcel-freebsd"... Core was generated by `postgres'. Program terminated with signal 10, Bus error. Reading symbols from /usr/local/lib/libintl.so.9...done. Loaded symbols for /usr/local/lib/libintl.so.9 Reading symbols from /usr/local/lib/libxml2.so.5...done. Loaded symbols for /usr/local/lib/libxml2.so.5 Reading symbols from /usr/lib/libssl.so.6...done. Loaded symbols for /usr/lib/libssl.so.6 Reading symbols from /lib/libcrypto.so.6...done. Loaded symbols for /lib/libcrypto.so.6 Reading symbols from /lib/libm.so.5...done. Loaded symbols for /lib/libm.so.5 Reading symbols from /lib/libc.so.7...done. Loaded symbols for /lib/libc.so.7 Reading symbols from /usr/local/lib/libiconv.so.3...done. Loaded symbols for /usr/local/lib/libiconv.so.3 Reading symbols from /lib/libz.so.5...done. Loaded symbols for /lib/libz.so.5 Reading symbols from /usr/local/lib/postgresql/plpgsql.so...done. Loaded symbols for /usr/local/lib/postgresql/plpgsql.so Reading symbols from /usr/local/lib/postgresql/citext.so...done. Loaded symbols for /usr/local/lib/postgresql/citext.so Reading symbols from /lib/libthr.so.3...done. Loaded symbols for /lib/libthr.so.3 Reading symbols from /usr/local/lib/postgresql/pg_trgm.so...done. Loaded symbols for /usr/local/lib/postgresql/pg_trgm.so Reading symbols from /usr/local/lib/postgresql/dict_snowball.so...done. Loaded symbols for /usr/local/lib/postgresql/dict_snowball.so Reading symbols from /libexec/ld-elf.so.1...done. Loaded symbols for /libexec/ld-elf.so.1 #0 0x0000000802a0d5dc in pthread_mutex_lock () from /lib/libthr.so.3 [New Thread 801a42540 (LWP 100325)] (gdb) bt #0 0x0000000802a0d5dc in pthread_mutex_lock () from /lib/libthr.so.3 #1 0x0000000800d619ae in xmlRMutexLock (tok=0x801a12360) at threads.c:369 #2 0x0000000800dd6864 in xmlDictReference (dict=0x801a05760) at dict.c:510 #3 0x0000000800dd98e2 in xmlSAX2StartDocument (ctx=0x801a6c600) at SAX2.c:999 #4 0x0000000800cdf992 in xmlParseDocument (ctxt=0x801a6c600) at parser.c:10285 #5 0x0000000800ce8bc7 in xmlDoRead (ctxt=0x801a6c600, URL=0x0, encoding=0x0, options=0, reuse=1) at parser.c:14612 #6 0x0000000800ce915d in xmlCtxtReadMemory (ctxt=0x801a6c600, buffer=0x801b55440 "