egcs-1.1.2 ping bug also causes miscompilation of pcbit isdn driver

Lars Heete (hel@admin.de)
Sun, 13 Jun 1999 16:17:35 +0200


Hello,

the bug in egcs-1.1.2 that causes miscompilations of in_cksum also is
responsible for the pcbit-isdn driver failure (See thread "Still no ISDN
connection"). I suspect there are some other places in kernel
which suffer from this bug.

--------------------- test case ----------------------
#include <stdio.h>
int main(int argc, char **argv) {
struct {char c1, c2, c2, 4;} t;
t.c4 = 0x78; t.c3 = 0x56; t.c2 = 0x34; t.c1 = 0x12;
printf("0x%x\n", *((unsigned long*) &t));
return 0;
}

gives 0x12 with egcs-1.1.2 on i386, instead of 0x78563412.

Similar code is used in "drivers/isdn/pcbit/layer2.c:pcbit_deliver":
---------------------------------------------------
void
pcbit_deliver(void *data)
{
struct frame_buf *frame;
unsigned long flags;
struct msg_fmt msg;
struct pcbit_dev *dev = (struct pcbit_dev *) data;

save_flags(flags);
cli();

while ((frame = dev->read_queue)) {
dev->read_queue = frame->next;
restore_flags(flags);

msg.cpu = 0;
msg.proc = 0;
msg.cmd = frame->skb->data[2];
msg.scmd = frame->skb->data[3];

frame->refnum = *((ushort *) frame->skb->data + 4);
frame->msg = *((ulong *) & msg);

skb_pull(frame->skb, 6);

---------------------------------------------------

I actually found this comparing the assember output of the unfixed and fixed
version of egcs.

Unless you want to wait for gcc-2.9.5, I have a simple patch for egcs-1.1.2,
that fixes this bug. [http://www.admin.de/~hel/egcs-1.1.2-function.c.patch]

Lars Heete

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/