From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Crash on attempt to connect to nonstarted server |
Date: | 2010-12-16 15:20:44 |
Message-ID: | 201012161520.oBGFKid09101@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Magnus Hagander wrote:
> I get a crash on win32 when connecting to a server that's not started.
> In fe-connect.c, we have:
>
> display_host_addr = (conn->pghostaddr == NULL) &&
> (strcmp(conn->pghost, host_addr) != 0);
>
> In my case, conn->pghost is NULL at this point, as is
> conn->pghostaddr. Thus, it crashes in strcmp().
I have researched this with Magnus, and was able to reproduce the
failure. It happens only on Win32 because that is missing unix-domain
sockets so "" maps to localhost, which is an IP address. I have applied
the attached patch. The new output is:
$ psql test
psql: could not connect to server: Connection refused
Is the server running on host "???" and accepting
TCP/IP connections on port 5432?
Note the "???". This happens because the mapping of "" to localhost
happens below the libpq library variable level.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachment | Content-Type | Size |
---|---|---|
/pgpatches/win32 | text/x-diff | 856 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-12-16 15:22:02 | Re: Question regarding psql or libpq |
Previous Message | Magnus Hagander | 2010-12-16 15:16:17 | Re: Re: Proposed Windows-specific change: Enable crash dumps (like core files) |