compiler warning

Started by Bruce Momjianalmost 15 years ago3 messages
#1Bruce Momjian
bruce@momjian.us

I am seeing the following compiler warning for the past few days:

basebackup.c:213: warning: variable `ptr' might be clobbered by
`longjmp' or `vfork'

and I see this comment in the file:

/*
* Actually do a base backup for the specified tablespaces.
*
* This is split out mainly to avoid complaints about "variable might be
* clobbered by longjmp" from stupider versions of gcc.
*/

Seems that isn't working as expected. I am using:

gcc version 2.95.3 20010315 (release)

with -O1.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

#2Magnus Hagander
magnus@hagander.net
In reply to: Bruce Momjian (#1)
Re: compiler warning

On Thu, Feb 3, 2011 at 04:40, Bruce Momjian <bruce@momjian.us> wrote:

I am seeing the following compiler warning for the past few days:

       basebackup.c:213: warning: variable `ptr' might be clobbered by
       `longjmp' or `vfork'

and I see this comment in the file:

       /*
        * Actually do a base backup for the specified tablespaces.
        *
        * This is split out mainly to avoid complaints about "variable might be
        * clobbered by longjmp" from stupider versions of gcc.
        */

Seems that isn't working as expected.  I am using:

       gcc version 2.95.3 20010315 (release)

with -O1.

This is the same warning Tom fixed earlier. I have no idea what
actually causes it :(

I think it's somehow caused by the PG_ENSURE_ERROR_CLEANUP stuff.
Does it go away if you break everything inside the if
(opt->includewal) into it's own function? (Or at least everything
except the pq_putemptymessage() call, because moving that would make
the code very confusing)

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

#3Bruce Momjian
bruce@momjian.us
In reply to: Magnus Hagander (#2)
1 attachment(s)
Re: compiler warning

Magnus Hagander wrote:

On Thu, Feb 3, 2011 at 04:40, Bruce Momjian <bruce@momjian.us> wrote:

I am seeing the following compiler warning for the past few days:

? ? ? ?basebackup.c:213: warning: variable `ptr' might be clobbered by
? ? ? ?`longjmp' or `vfork'

and I see this comment in the file:

? ? ? ?/*
? ? ? ? * Actually do a base backup for the specified tablespaces.
? ? ? ? *
? ? ? ? * This is split out mainly to avoid complaints about "variable might be
? ? ? ? * clobbered by longjmp" from stupider versions of gcc.
? ? ? ? */

Seems that isn't working as expected. ?I am using:

? ? ? ?gcc version 2.95.3 20010315 (release)

with -O1.

This is the same warning Tom fixed earlier. I have no idea what
actually causes it :(

I think it's somehow caused by the PG_ENSURE_ERROR_CLEANUP stuff.
Does it go away if you break everything inside the if
(opt->includewal) into it's own function? (Or at least everything
except the pq_putemptymessage() call, because moving that would make
the code very confusing)

I added the attached C comment so we know why the warning is generated.
We can remove it later if we want, but I want to have it if we get
reports about 9.1 problems.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachments:

/rtmp/clobber.difftext/x-diffDownload
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index b5cda50..d94b61f 100644
*** a/src/backend/replication/basebackup.c
--- b/src/backend/replication/basebackup.c
*************** perform_base_backup(basebackup_options *
*** 217,222 ****
--- 217,228 ----
  				ptr.xlogid = logid;
  				ptr.xrecoff = logseg * XLogSegSize + TAR_SEND_SIZE * i;
  
+ 				/*
+ 				 *	Some old compilers, e.g. 2.95.3/x86, think that passing
+ 				 *	a struct in the same function as a longjump might clobber
+ 				 *	a variable.  bjm 2011-02-04
+ 				 *	http://lists.apple.com/archives/xcode-users/2003/Dec//msg00051.html
+ 				 */
  				XLogRead(buf, ptr, TAR_SEND_SIZE);
  				if (pq_putmessage('d', buf, TAR_SEND_SIZE))
  					ereport(ERROR,