On Tue, 2009-07-28 at 23:38 -0400, Josh Williams wrote:
> Huh, running the patched version on a single thread with 128 clients
> just got it to crash.  Actually consistently, three times now.  Will try
> the same thing on the development box tomorrow morning to get some
> better debugging information.

So yeah, buffer overrun.

In pgbench.c FD_SETSIZE is redefined to get around the Windows default
of 64.  But this is done after bringing in winsock2.h (a couple levels
in as a result of first including postgres_fe.h).  So any fd_set is
built with an array of 64 descriptors, while pgbench thinks it has 1024
available to work with.

This was introduced a while back; the multi-threaded patch just makes it
visible by giving it an important pointer to write over.  Previously it
would just run over into the loop counter (and probably a couple other
things) and thus it'd continue on happily with the [sub]set it has.

In either case this seems to be a simple fix, to move that #define
earlier (see pgbench_win32.patch.)

- Josh Williams

diff -c -r1.87 pgbench.c
*** contrib/pgbench/pgbench.c	11 Jun 2009 14:48:51 -0000	1.87
--- contrib/pgbench/pgbench.c	29 Jul 2009 21:18:18 -0000
***************
*** 26,31 ****
--- 26,36 ----
   * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
   *
   */
+ 
+ #ifdef WIN32
+ #define FD_SETSIZE 1024		/* set before winsock2.h is included */
+ #endif   /* ! WIN32 */
+ 
  #include "postgres_fe.h"
  
  #include "libpq-fe.h"
***************
*** 34,41 ****
  #include <ctype.h>
  
  #ifdef WIN32
- #undef FD_SETSIZE
- #define FD_SETSIZE 1024
  #include <win32.h>
  #else
  #include <signal.h>
--- 39,44 ----
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to