Hi Stéphane,

looks like you are compiling your code with compiler flags that generate instructions that the processor does not support. That's why you see the illegal instruction trap.

The reason that it all works if the variables are local is probably that you also use an optimization flag (e.g. -O3) that causes the compiler to optimize the whole multiplication away in main because it has no effect on the function's result and is local to the function.

You should try to compile the code with gcc -S to generate assembler output. Then you can identify the instruction that causes the problem.

Cheers,
   Wolfgang

Stéphane wrote:
Hi,

I have a bug that I can be resume as:

/***************************/
#include <linux/module.h>    // Needed by all modules
#include <linux/kernel.h>    // Needed for KERN_INFO

static long global_right_encoder;
static long global_left_encoder;
static long VitL;

int init_module(void)
{
    VitL = 0;
    global_left_encoder = 0;
    global_right_encoder = 0;

    printk(KERN_INFO "Bug:\n");
VitL = global_left_encoder*global_right_encoder; printk(KERN_INFO "Never Reach\n"); return 0;
}


void cleanup_module(void)
{
}

MODULE_AUTHOR("Stephane Germain");
MODULE_LICENSE("GPL");
/**********************************/

result:

insmod xxx.o:
SIGSEGV

dmesg:
Bug:
*** ILLEGAL INSTRUCTION ***   FORMAT=0
Current process id is 47
BAD KERNEL TRAP: 00000000
PC: [<000a8bec>]
SR: 2014  SP: 007dbee8  a2: 10c16b34
d0: 00000000    d1: 00000991    d2: 00000000    d3: ffffffea
d4: 00000060    d5: 00000008    a0: 0003dc8c    a1: 0003dca8
Process insmod (pid: 47, stackpage=007db000)
Frame format=0
Stack from 007dbf1c:
        000a8c14 007d3000 007dbfc4 10c17856 007c5348 00102428 007c5348
000000e8
        00000002 00000001 007da000 00192e00 007c51c0 00190004 00140560
0015fae0
        007d3000 007d4000 00000060 0003dd58 000a8bc0 000000e8 00000000
00000000
        00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
        00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
        00000000 00000000 0019fdc8 10c127d2 00192e00 007c5348 00102428
007c5348
Call Trace:
        [<10c17856>] [<10c127d2>]
Code: 4c39 0800 000a 8c3c 23c0 000a 8c44 4879 000a 8c1d

/*****************************/


if the variables are local, all work!

Somebody know something that I don't  about that?

Thanks

Stephane Germain



_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to