From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: CompactCheckpointerRequestQueue versus pad bytes |
Date: | 2012-07-16 16:16:23 |
Message-ID: | CA+TgmobBa3cM4eLzVJM+dz88F4x1x5b5ydA9hFOas3uwu6YJJA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jul 16, 2012 at 11:44 AM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> I wouldn't rely on that, though. I wouldn't be surprised if there was some
> debugging flag or similar that initialized all pages to random values or
> 0xdeadbeef or something, before handing them out to the application. We
> could easily zero all shared memory on allocation ourselves, though.
Well, the documentation for mmap (which we're currently using) on Linux says:
MAP_ANONYMOUS
The mapping is not backed by any file; its contents are initial‐
ized to zero. The fd and offset arguments are ignored; however,
some implementations require fd to be -1 if MAP_ANONYMOUS (or
MAP_ANON) is specified, and portable applications should ensure
this. The use of MAP_ANONYMOUS in conjunction with MAP_SHARED
is only supported on Linux since kernel 2.4.
shmget says:
When a new shared memory segment is created, its contents are initial‐
ized to zero values, and its associated data structure, shmid_ds (see
shmctl(2)), is initialized as follows:
And shm_open says:
A new shared memory object initially has zero length — the
size of the object can be set using ftruncate(2). The newly
allocated bytes of a shared memory object are automatically
initialized to 0.
The documentation on MacOS X isn't quite as explicit, but I'd still be
astonished if we found any other behavior. TBH, I'd be kind of
surprised if this is the only place in our code base that relies on
the initial contents of shared memory being all-zeros. If we really
care about that we probably ought to make --enable-cassert write
0xdeadbeef all over the whole shared-memory segment on startup, or
something like that, because otherwise it's only a matter of time
before someone will break it. Personally I'd like to see some
evidence that the problem is more than strictly hypothetical before we
spend time on it, though.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2012-07-16 16:26:06 | Re: [PERFORM] DELETE vs TRUNCATE explanation |
Previous Message | Tom Lane | 2012-07-16 16:16:11 | Re: CompactCheckpointerRequestQueue versus pad bytes |