Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > Re: [GENERAL] p...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 9611 of 11013
Post > Topic >>

Re: [GENERAL] pg cra****ng

by magnus@[EMAIL PROTECTED] (Magnus Hagander) Jul 2, 2008 at 06:46 PM

This is a multi-part message in MIME format.
--------------050603000007060909030609
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

[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

--------------050603000007060909030609
Content-Type: text/x-diff;
 name="win32_shmem.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="win32_shmem.diff"

Index: win32_shmem.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/****t/win32_shmem.c,v
retrieving revision 1.4
diff -c -r1.4 win32_shmem.c
*** win32_shmem.c	1 Jan 2008 19:45:51 -0000	1.4
--- win32_shmem.c	2 Jul 2008 16:44:40 -0000
***************
*** 47,64 ****
  		elog(FATAL, "could not get size for full pathname of datadir %s: %lu",
  			 DataDir, GetLastError());
  
! 	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);
  	if (r == 0 || r > bufsize)
  		elog(FATAL, "could not generate full pathname for datadir %s: %lu",
  			 DataDir, GetLastError());
  
! 	for (cp = retptr; *cp; cp++)
  		if (*cp == '\\')
  			*cp = '/';
  
--- 47,64 ----
  		elog(FATAL, "could not get size for full pathname of datadir %s: %lu",
  			 DataDir, GetLastError());
  
! 	retptr = malloc(bufsize  + 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 + 18, NULL);
  	if (r == 0 || r > bufsize)
  		elog(FATAL, "could not generate full pathname for datadir %s: %lu",
  			 DataDir, GetLastError());
  
! 	for (cp = retptr + 18; *cp; cp++)
  		if (*cp == '\\')
  			*cp = '/';
  

--------------050603000007060909030609
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--------------050603000007060909030609--
 




 3 Posts in Topic:
Re: [GENERAL] pg crashing
magnus@[EMAIL PROTECTED]   2008-07-02 18:46:31 
Re: [GENERAL] pg crashing
tgl@[EMAIL PROTECTED] (T  2008-07-02 19:06:04 
Re: [GENERAL] pg crashing
magnus@[EMAIL PROTECTED]   2008-07-04 12:27:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 9:03:16 CST 2008.