This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: #pragma push breaks bootstrap?


Nick Clifton wrote:
> Hi Robert,
> 
> : I walked through the patches of the last 24 hours and one of the most
> : benign looking of the lot seems to be thing that triggers it.  If I
> : revert i386/i386.h to -D981001 so that HANDLE_PRAGMA_PACK_PUSH_POP isn't
> : set and redo the bootstrap, it works.  If I walk that lone file forward
> : to the -D981002 tag and redo the bootstrap, it does the wrong thing.  The
> : whole thing just reeks of a memory overwrite somewhere.
> 
> I agree, although I am stumped as to where the bug might lie.
> 
> I eyeballed my code, and I do not see how it could be affecting you.

I eyeballed your code, too.  In light of this message, it occurs to me
that I was looking for a forest instead of trees.  I was looking for 
malloc() bozos, off-by-ones and the like.   It didn't occur to me that
the new code might actually be _used_ :-)


> (I am assuming that none of your system header files actually use
> #pragma pack(..).  If they do, then maybe this might be the cause).

Only about 1300 times.

(robertl) rjlhome:/usr/include 
$ grep 'pragma.*pack' `find . -name \*.h -print` | wc -l
   1324

> : The difference between the two versions is in the .s files.   When
> : PRAGMA_PUSH and friends are turned on, egcs emits wrong offsets into
> : the __iob array that is used by things like the 'fflush(stdout)' that

> Hmmm, I take it back - it does look like your headers use #pragma
> pack push(...).  The effect of the pragma is to change the packing of

It honestly didn't occur to me that it was packing the iob structure.
This certainly explains things.

I see zero occurrences of 'pragma.*pack.*push' in system headers.

> fields inside structures.  The point of this patch was to support the
> way Microsoft's Visual C compiler implememnts the pragma, and so allow
> Cygwin and pals to use MS system header files.

Since some of the OpenServer headers have Microsoft heritage and SCO
used to use the Microsoft compilers, it is likely that these have common
genealogy.

> My guess is that <stdio.h> or one of its descendants is defining
> #pragma pack, and that either a) the HANDLE_PRAGMA_PACK_PUSH_POP code
> is not handling the pragma correctly, or b) there is difference in the
> behaviour of #pragma pack between OpenServer and Win32.

Yes, this is starting to make much more sense now.

> 	a. #pragma pack is being used by your system header files

Yes.

I can send you samples if you like, but they essentially look something
like:

#ifndef _STDIO_H
#define _STDIO_H

#pragma comment(exestr, "xpg4plus @(#) stdio.h 20.2 95/12/11 ")

#pragma pack(4)

#ifdef __cplusplus
extern "C" {
#endif

[ meat of header munched ] 

#pragma pack()

#endif /* _STDIO_H */
#endif



> and	b. If so, is there any documentation on how the pragma is
> 	supposed to behave.

I thought it was a pretty typical implementation of pragma pack, but
I'm surely biased by a decade of SCO experience. :-)

This document contains a pretty decent defintion of how these tools 
work.

	http://www.sco.com/cgi-bin/ssl_reference?100379

Without an actual examaination of c-pragma.c, I'm wonder if it's
matching 'pragma pack('s that don't have the 'push' or 'pop' keywords.


Thanx for the help.
RJL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]