From: Andres Freund <andres@2ndquadrant.com>
To: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: abort()/segfault when starting postgres in inaccessible CWD
Date: Thu, 3 Oct 2013 18:11:39 +0200
Message-ID: <20131003161139.GA28301@awork2.anarazel.de> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Hi,
Starting postgres with a CWD that's not readable will trigger an Assert
and if those are disabled it presumably will segfault.
#0 0x00007ffff75621e5 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff7565398 in __GI_abort () at abort.c:90
#2 0x000000000089031d in ExceptionalCondition (
conditionName=0xa6e530 "!(((CurrentMemoryContext) != ((void *)0) && (((((const Node*)((CurrentMemoryContext)))->type) == T_AllocSetContext))))", errorType=0xa6e2c9 "BadArgument", fileName=0xa6e240 "/home/andres/src/postgresql/src/backend/utils/mmgr/mcxt.c", lineNumber=649)
at /home/andres/src/postgresql/src/backend/utils/error/assert.c:54
#3 0x00000000008bc206 in palloc (size=1024) at /home/andres/src/postgresql/src/backend/utils/mmgr/mcxt.c:649
#4 0x00000000006597b2 in initStringInfo (str=0x7fffffffc410) at /home/andres/src/postgresql/src/backend/lib/stringinfo.c:50
#5 0x0000000000896383 in expand_fmt_string (fmt=0xa8d3e8 "could not change directory to \"%s\": %s", edata=0xd587e0 <errordata>)
at /home/andres/src/postgresql/src/backend/utils/error/elog.c:3167
#6 0x0000000000892c52 in elog_finish (elevel=15, fmt=0xa8d3e8 "could not change directory to \"%s\": %s")
at /home/andres/src/postgresql/src/backend/utils/error/elog.c:1297
#7 0x00000000008d932a in resolve_symlinks (path=0x7fffffffdad0 "/home/andres/build/postgres/dev-assert/vpath/src/backend/postgres")
at /home/andres/src/postgresql/src/port/exec.c:293
#8 0x00000000008d8e10 in find_my_exec (argv0=0xd60bb0 "/home/andres/build/postgres/dev-assert/vpath/src/backend/postgres",
retpath=0x7fffffffdad0 "/home/andres/build/postgres/dev-assert/vpath/src/backend/postgres")
at /home/andres/src/postgresql/src/port/exec.c:144
#9 0x00000000008d96aa in set_pglocale_pgservice (argv0=0xd60bb0 "/home/andres/build/postgres/dev-assert/vpath/src/backend/postgres",
app=0xa05440 "postgres-9.4") at /home/andres/src/postgresql/src/port/exec.c:561
#10 0x0000000000668932 in main (argc=21, argv=0xd60af0) at /home/andres/src/postgresql/src/backend/main/main.c:98
So, the problem is that we're calling set_pglocale_pgservice() which
indirectly can call elog() long before we've initialized memory
contexts.
To reproduce do something like:
# become root
su
# change into root-only directory
cd /root
# switch user, without changing directory
su postgres
# execute postgres
/path/to/postgres -D frakbar
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andres@2ndquadrant.com
Subject: Re: abort()/segfault when starting postgres in inaccessible CWD
In-Reply-To: <20131003161139.GA28301@awork2.anarazel.de>
References: <20131003161139.GA28301@awork2.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox