pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6460: routine my_log2 use incorrect data type ?
3+ messages / 3 participants
[nested] [flat]

* BUG #6460: routine my_log2 use incorrect data type ?
@ 2012-02-17 05:25  zoulx1982@163.com
  0 siblings, 2 replies; 3+ messages in thread

From: zoulx1982@163.com @ 2012-02-17 05:25 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      6460
Logged by:          lxzou
Email address:      zoulx1982@163.com
PostgreSQL version: 9.1.2
Operating system:   Windows Server 2008 64 bit
Description:        

Hi,
 I startup postgres in win server 2008 64-bit with
shared_buffers=1073741819, but find it doesn't work.

I debug the postgres use vs2008, and find it enter an Infinite loop in
my_log2.

when the parameter num is between (2^30) + 1 and (2^31) -1, it will be an
Infinite loop.

because long in win 64 is 4 bytes, so (2^30) << 1 is 2^31, i.e. -2^31.
move left again it will be zero.

size_t in win64 is 8 bytes,so add_size and mul_size can't check overflow,
but in win32 it can do that.

So, whether we should use Size instead of long ?

Best wishes




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #6460: routine my_log2 use incorrect data type ?
@ 2012-02-17 22:27  Tom Lane <tgl@sss.pgh.pa.us>
  parent: zoulx1982@163.com
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2012-02-17 22:27 UTC (permalink / raw)
  To: zoulx1982@163.com; +Cc: pgsql-bugs

zoulx1982@163.com writes:
>  I startup postgres in win server 2008 64-bit with
> shared_buffers=1073741819, but find it doesn't work.

Well, that's hardly the fault of my_log2.  What you should have gotten
is

FATAL:  requested shared memory size overflows size_t

and I do get that when I try that value.  Apparently the overflow check
in mul_size() is broken in your build.   Did you build it yourself, and
if so with which compiler and what compilation options?  If you didn't
build it yourself, where did you get it from?

> size_t in win64 is 8 bytes, so add_size and mul_size can't check overflow,

Sure they can.  Or at least if they can't, it's not because of size_t
being 8 bytes.  That code works fine on every other 64-bit platform.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #6460: routine my_log2 use incorrect data type ?
@ 2012-02-18 08:34  zoulx1982 <zoulx1982@163.com>
  parent: zoulx1982@163.com
  1 sibling, 0 replies; 3+ messages in thread

From: zoulx1982 @ 2012-02-18 08:34 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

yes, I  build it by myself, and the version is 9.1.2, following is my build process.
1.  in Visual Studio 2008 x64 cmd, exec  "set CONFIG=DEBUG"
2.  exec "build" , and i see "Detected hardware platform: x64"
3. exec "perl install.pl install2 Debug"
4. cd ****/install2
5. initdb a data dir, "initdb.exe -Atrust -USYSTEM --no-locale -D ../data"
6. startup postgres ""postgres" -D "../data" -c shared_buffers=1073741819"
 
above is my build process, and whether one of these steps incorrect ?
 
here is stack info
 postgres.exe!my_log2(long num=1073741835)  行1397 + 0x1e 字节 C
  postgres.exe!hash_estimate_size(long num_entries=1073741835, unsigned __int64 entrysize=24)  行626 + 0x9 字节 C
  postgres.exe!BufTableShmemSize(int size=1073741835)  行46 C
  postgres.exe!StrategyShmemSize()  行287 + 0xe 字节 C
  postgres.exe!BufferShmemSize()  行175 + 0x5 字节 C
  postgres.exe!CreateSharedMemoryAndSemaphores(char makePrivate=0, int port=5432)  行107 + 0x5 字节 C
  postgres.exe!reset_shared(int port=5432)  行2122 C
  postgres.exe!PostmasterMain(int argc=5, char * * argv=0x0000000000873590)  行971 C
  postgres.exe!main(int argc=5, char * * argv=0x0000000000873590)  行199 + 0xe 字节 C

 
best wishes

At 2012-02-18 06:27:04,"Tom Lane" <tgl@sss.pgh.pa.us> wrote:
>zoulx1982@163.com writes:
>>  I startup postgres in win server 2008 64-bit with
>> shared_buffers=1073741819, but find it doesn't work.
>
>Well, that's hardly the fault of my_log2.  What you should have gotten
>is
>
>FATAL:  requested shared memory size overflows size_t
>
>and I do get that when I try that value.  Apparently the overflow check
>in mul_size() is broken in your build.   Did you build it yourself, and
>if so with which compiler and what compilation options?  If you didn't
>build it yourself, where did you get it from?
>
>> size_t in win64 is 8 bytes, so add_size and mul_size can't check overflow,
>
>Sure they can.  Or at least if they can't, it's not because of size_t
>being 8 bytes.  That code works fine on every other 64-bit platform.
>
> regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2012-02-18 08:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-02-17 05:25 BUG #6460: routine my_log2 use incorrect data type ? zoulx1982@163.com
2012-02-17 22:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-02-18 08:34 ` zoulx1982 <zoulx1982@163.com>

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