Re: [GENERAL] pg crashing

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] pg crashing
Date: 2008-07-02 16:46:31
Message-ID: 486BB0E7.3060009@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

[moving over to hackers]

Tom Lane wrote:
> BTW, just looking at win32_shmem.c ...
>
> retptr = malloc(bufsize + 1 + 18); /* 1 NULL and 18 for
> * Global\PostgreSQL: */
> if (retptr == NULL)
> elog(FATAL, "could not allocate memory for shared memory name");
>
> strcpy(retptr, "Global\\PostgreSQL:");
> r = GetFullPathName(DataDir, bufsize, retptr + 11, NULL);
>
> Surely that "11" ought to be "18". Also, since the loop immediately

Yes. Very true. It still *works*, since it guts off on the proper side
of the \, but it still makes sense.

> below this is going to convert \ to /, wouldn't it be clearer to
> describe the path prefix as Global/PostgreSQL: in the first place?

Eh, that shows another bug I think. It should *not* convert the \ in
"Global\", because that one is is interpreted by the Win32 API call!

I think it should be per this patch. Seems right?

> (BTW, as far as I can tell the +1 added to the malloc request is
> useless: bufsize includes the trailing null, and the code would
> not work if it did not.)

Yeah, also true.

//Magnus

Attachment Content-Type Size
win32_shmem.diff text/x-diff 1.5 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chandra Barnett 2008-07-02 17:09:49 Re: Problem with roles and permissions
Previous Message jcvlz 2008-07-02 16:22:51 Re: simple tool for building web forms

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-07-02 16:52:47 Re: WIP patch: reducing overhead for repeat de-TOASTing
Previous Message Peter Eisentraut 2008-07-02 16:44:37 Re: Postgresql 8.3 issue