[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Gcc 3.x seems to create incorrect code

In message <m37kcvhqn1.fsf@mira.informatik.hu-berlin.de>
          martin@v.loewis.de (Martin v. Löwis) wrote:

> Miah Gregory <mace@darksilence.net> writes:

> > As such, I've come here in the hope that someone can suggest how I might
> > find out the exact cause of the problem, as I've never had to try and
> > track down potential compiler bugs before.

Turns out that it's not a compiler bug, but a workaround in the kernel for
a compiler bug.. :-)

See "include/linux/spinlock.h", and search for gcc_is_buggy.

What was happening, is that the extra field caused the structure to be
larger. The kernel was compiled with 2.95.4, and therefore had this field
in place. The module, being compiled with 3.2.2, didn't have the field, and
consequently was reading from the wrong place in the structure.

> We are certainly interested to eliminate all compiler bugs that cause
> kernel miscompilation. Please understand, though, that you don't
> *necessarily* have encountered a compiler bug: It may be that you rely
> on undefined or unspecified behaviour in your code, and that gcc 3.2
> choses to interpret your code differently than 2.95. In this case, you
> need to correct your code, to only use well-defined constructs.

Absolutely, that's why I used the term 'possible compiler bug'. No-one's
perfect, least of all myself. :-)

Thanks for the prompt response.

Miah Gregory

Reply to: