public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* A bug present in 3.2
@ 2003-10-21 21:52 Stelios Xanthakis
  2003-10-27  6:39 ` Jim Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Stelios Xanthakis @ 2003-10-21 21:52 UTC (permalink / raw)
  To: gcc


Hi.

In gcc32, if you put a static local variable of 
a static inline function into a ".gnu.linkonce.d"
section, it crashes.

The sections appear to be correct in object files,
so this is probably a linker problem.

This is fixed in 3.3/3.4?

Any other way we can work around static locals of
static inline functions? (we want one storage for all object files)



Thanks

stelios

// CC:


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

* Re: A bug present in 3.2
  2003-10-21 21:52 A bug present in 3.2 Stelios Xanthakis
@ 2003-10-27  6:39 ` Jim Wilson
  2003-10-27 14:17   ` Stelios Xanthakis
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Wilson @ 2003-10-27  6:39 UTC (permalink / raw)
  To: Stelios Xanthakis; +Cc: gcc

Stelios Xanthakis wrote:
> In gcc32, if you put a static local variable of 
> a static inline function into a ".gnu.linkonce.d"
> section, it crashes.

How are you putting the local variables in a .gnu.linkonce.d section? 
We need a testcase, and command line options.

Also, what exactly is crashing?  The compiler?  Or the linker?

For infromation about how to report bugs, see
	http://gcc.gnu.org/bugs.html

> The sections appear to be correct in object files,
> so this is probably a linker problem.

If the linker is crashing, then this is a binutils problem, not a gcc 
problem.  Send mail to binutils@sources.redhat.com.

> This is fixed in 3.3/3.4?

I don't know what bug you are reporting, so I can't tell if it is 
already fixed.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

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

* Re: A bug present in 3.2
  2003-10-27  6:39 ` Jim Wilson
@ 2003-10-27 14:17   ` Stelios Xanthakis
  2003-10-27 23:46     ` Jim Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Stelios Xanthakis @ 2003-10-27 14:17 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc



On Sun, 26 Oct 2003, Jim Wilson wrote:

> Stelios Xanthakis wrote:
> > In gcc32, if you put a static local variable of 
> > a static inline function into a ".gnu.linkonce.d"
> > section, it crashes.
> 
> How are you putting the local variables in a .gnu.linkonce.d section? 
> We need a testcase, and command line options.
> 
> Also, what exactly is crashing?  The compiler?  Or the linker?
> 

Ops. sorry. The generated a.out file crashes when you run it.
My bad. Too much coffee.

Typescript of problem follows:
-----------------------------
Script started on Tue Oct 21 23:39:20 2003
stan@linux:~/wtmp/inline> cat H.h
#include <stdio.h>

static inline int f ()
{
	static int i __attribute__ ((__section__(".gnu.linkonce.d.i")));
	return i++;
}
stan@linux:~/wtmp/inline> cat M1.c

#include "H.h"

void foo ()
{
	printf ("F=%i\n", f());
	printf ("F=%i\n", f());
	printf ("F=%i\n", f());
}
stan@linux:~/wtmp/inline> cat M2.c
#include "H.h"

extern void foo ();

int main ()
{
	printf ("%i\n", f());
	printf ("%i\n", f());
	printf ("%i\n", f());
	foo ();
}
stan@linux:~/wtmp/inline> gcc -g M1.c M2.c
stan@linux:~/wtmp/inline> ./a.out
Segmentation fault
stan@linux:~/wtmp/inline> valgrind a.out
==4084== valgrind-1.0.4, a memory error detector for x86 GNU/Linux.
==4084== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==4084== Estimated CPU clock rate is 535 MHz
==4084== For more details, rerun with: -v
==4084== 
==4084== Invalid read of size 4
==4084==    at 0x804840E: f (H.h:4)
==4084==    by 0x4024C4F2: __libc_start_main (in /lib/libc.so.6)
==4084==    by 0x80482A1: (within /home/stan/wtmp/inline/a.out)
==4084==    Address 0x0 is not stack'd, malloc'd or free'd
Segmentation fault
(gdb) stan@linux:~/wtmp/inline> gdb ./a.out
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...
(gdb) r
Starting program: /home/stan/wtmp/inline/a.out 

Program received signal SIGSEGV, Segmentation fault.
f () at H.h:6
6		return i++;
(gdb) li
1	#include <stdio.h>
2	
3	static inline int f ()
4	{
5		static int i __attribute__ ((__section__(".gnu.linkonce.d.i")));
6		return i++;
7	}
(gdb) print &i
$1 = (int *) 0x0
(gdb) The program is running.  Exit anyway? (y or n) stan@linux:~/wtmp/inline> 
stan@linux:~/wtmp/inline> gcc --version
gcc (GCC) 3.2
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

stan@linux:~/wtmp/inline> 
Script done on Tue Oct 21 23:42:33 2003

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

* Re: A bug present in 3.2
  2003-10-27 14:17   ` Stelios Xanthakis
@ 2003-10-27 23:46     ` Jim Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Jim Wilson @ 2003-10-27 23:46 UTC (permalink / raw)
  To: Stelios Xanthakis; +Cc: gcc

On Mon, 2003-10-27 at 01:09, Stelios Xanthakis wrote:
> static inline int f ()
> {
> 	static int i __attribute__ ((__section__(".gnu.linkonce.d.i")));
> 	return i++;
> }

That is an interesting looking trick, but it isn't clear if we can make
it work.  Having the variable be both static and in a linkonce section
seems somehow contradictory to me.

The immediate problem seems to be with ld.  I suggest you mention it on
the binutils mailing list.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

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

end of thread, other threads:[~2003-10-27 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-21 21:52 A bug present in 3.2 Stelios Xanthakis
2003-10-27  6:39 ` Jim Wilson
2003-10-27 14:17   ` Stelios Xanthakis
2003-10-27 23:46     ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).