Re: 9.2 beta2 - pg_ctl crashes on Win32 when neither PGDATA nor -D specified

From: Edmund Horner <ejrh00(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: 9.2 beta2 - pg_ctl crashes on Win32 when neither PGDATA nor -D specified
Date: 2012-06-12 03:37:39
Message-ID: CAMyN-kD12kDaZuyp-CY_ZeFd2+HoFmc+YXGRtpX=vy+VU=ygZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 12 June 2012 14:51, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Edmund Horner <ejrh00(at)gmail(dot)com> writes:
>> On 12 June 2012 14:23, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Hm, that patch seems to be several bricks shy of a load.  I will fix
>>> two obvious bugs in it:
>>> (1) not dump core on boxes where printf("%s", NULL) dumps core;
>
>> I saw that, but I couldn't decide if it was the actual problem in my
>> case.  Later parts of adjust_data_dir appeared to be running (looking
>> at file system activity).
>
> The weird thing is that if it's not dumping core, the first fopen would
> presumably be trying to open "/postgresql.conf", which generally ought
> to fail and thus mask any problems in the rest of adjust_data_dir().
> Have you by any chance got a postgresql.conf laying about in your root
> directory?

I don't, and I couldn't see any file system requests for
postgresql.conf either (though I thought that might be because it's
failing to find a bogus parent path first e.g. something like
"(null)/postgresql.conf". But I think it's just a problem in the
snprintf statements after all:

I've managed to run it in the MSVC debugger, using the packaged pdb
files. So it does seem to be crashing on the first snprintf
statement.

pg_ctl.exe!fmtstr(char * value=0x00000000, int leftjust=0, int
minlen=1, int maxwidth=0, int pointflag=0, PrintfTarget *
target=0x00000000) Line 779 + 0x6 bytes C
pg_ctl.exe!dopr(PrintfTarget * target=0x0081f72c, const char *
format=0x0040b948, char * args=0x00000000) Line 715 + 0x1c bytes C
pg_ctl.exe!pg_snprintf(char * str=0x0081fb5c, unsigned int
count=1024, const char * fmt=0x0040b948, ...) Line 171 + 0x35 bytes C
> pg_ctl.exe!adjust_data_dir() Line 1902 C
pg_ctl.exe!main(int argc=2, char * * argv=0x00da4fe0) Line 2189 C
pg_ctl.exe!__tmainCRTStartup() Line 555 + 0x17 bytes C
kernel32.dll!7c817067()
[Frames below may be incorrect and/or missing, no symbols loaded for
kernel32.dll]

I'm not sure I can find the exact source version pg_ctl.c that was
compiled -- I get an off-by-one error around line 1902 using the
source from a few days ago.

1900 /* If there is no postgresql.conf, it can't be a config-only dir */
1901 snprintf(filename, sizeof(filename), "%s/postgresql.conf", pg_config);
1902 if ((fd = fopen(filename, "r")) == NULL)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Edmund Horner 2012-06-12 05:10:19 Re: PostgreSQL 9.2 beta1's pg_upgrade fails on Windows XP
Previous Message Tom Lane 2012-06-12 02:51:50 Re: 9.2 beta2 - pg_ctl crashes on Win32 when neither PGDATA nor -D specified