LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Problems with illegal instruction (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/problems-with-illegal-instruction-802994/)

ligang 04-20-2010 12:30 AM

Problems with illegal instruction
 
Hi all!
What is the reason behind this message:
Code:

Program received signal SIGILL, Illegal instruction.
0x0005e3d8 in ejsDefineStandardProperties (obj=0x1) at ejsProcs.c:618
618    {
Current language:  auto; currently c
(gdb) list ejsDefineStandardProperties
613    /*
614      *      Define the standard properties and functions inherited by all script engines.
615      */
616
617    int ejsDefineStandardProperties(MprVar *obj)
618    {
619    #if BLD_FEATURE_FLOATING_POINT
620            mprCreatePropertyValue(obj, "NaN", mprCreateFloatVar(0.0 / ejsValue(0.0)));
621            mprCreatePropertyValue(obj, "Infinity",
622                    mprCreateFloatVar(ejsValue(MAX_FLOAT) * ejsValue(MAX_FLOAT)));
(gdb) list
623    #endif
624            mprCreatePropertyValue(obj, "null", mprCreateNullVar());
625            mprCreatePropertyValue(obj, "undefined", mprCreateUndefinedVar());
626            mprCreatePropertyValue(obj, "true", mprCreateBoolVar(1));
627            mprCreatePropertyValue(obj, "false", mprCreateBoolVar(0));
628
629    #if BLD_FEATURE_LEGACY_API
630            /*
631              *      DEPRECATED: 2.0.
632              *      So that ESP/ASP can ignore "language=javascript" statements
(gdb) list
633              */
634            mprCreatePropertyValue(obj, "javascript", mprCreateIntegerVar(0));
635    #endif
636
637            /*
638              *      Extension functions
639              */
640            mprCreatePropertyValue(obj, "assert",
641                    mprCreateCFunctionVar(assertProc, 0, MPR_VAR_SCRIPT_HANDLE));
642            mprCreatePropertyValue(obj, "eval",
(gdb) list
643                    mprCreateCFunctionVar(evalScriptProc, 0, MPR_VAR_SCRIPT_HANDLE));
644            mprCreatePropertyValue(obj, "exit",
645                    mprCreateCFunctionVar(exitProc, 0, MPR_VAR_SCRIPT_HANDLE));
646            mprCreatePropertyValue(obj, "refCount",
647                    mprCreateCFunctionVar(refCountProc, 0, MPR_VAR_SCRIPT_HANDLE));
648            mprCreatePropertyValue(obj, "print",
649                    mprCreateCFunctionVar(printProc, 0, MPR_VAR_SCRIPT_HANDLE));
650            mprCreatePropertyValue(obj, "println",
651                    mprCreateCFunctionVar(printlnProc, 0, MPR_VAR_SCRIPT_HANDLE));
652            mprCreatePropertyValue(obj, "printVars",
(gdb) list
653                    mprCreateCFunctionVar(printVarsProc,0, MPR_VAR_SCRIPT_HANDLE));
654            mprCreatePropertyValue(obj, "trace",
655                    mprCreateStringCFunctionVar(traceProc, 0, MPR_VAR_SCRIPT_HANDLE));
656
657            /*
658              *      Constructors
659              */
660            mprCreatePropertyValue(obj, "Array",
661                    mprCreateCFunctionVar(arrayConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
662            mprCreatePropertyValue(obj, "Boolean",
(gdb) list
663                    mprCreateCFunctionVar(booleanConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
664            mprCreatePropertyValue(obj, "Object",
665                    mprCreateCFunctionVar(objectConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
666            mprCreatePropertyValue(obj, "Number",
667                    mprCreateCFunctionVar(numberConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
668            mprCreatePropertyValue(obj, "String",
669                    mprCreateCFunctionVar(stringConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
670
671            /*      mprCreatePropertyValue(obj, "Date",
672              *              mprCreateCFunctionVar(dateConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
(gdb) list
673              *      mprCreatePropertyValue(obj, "Regexp",
674              *              mprCreateCFunctionVar(regexpConsProc, 0, MPR_VAR_SCRIPT_HANDLE));
675              */
676
677            /*
678              *      Can we use on var x = "string text";
679              */
680            return 0;
681    }


rylan76 04-21-2010 06:22 AM

Hmm the only time I've seen this was when I was using GCC to compile an app for an AMD CPU, but I chose an Intel CPU target.

This -might- be the cause of the "illegal instruction" you are getting - what happened to me whenever I tried to run the "Intel" binary on my AMD machine was that the binary tried to execute Intel specific instructions on an AMD architecture, which of course did not work.

I. e. my CFLAGS sent to GCC were

Code:

-O3 -fomit-frame-pointer -ffast-math -fexpensive-optimizations -fstrict-aliasing -funroll-loops -funroll-all-loops -fforce-addr -finline-functions -frerun-loop-opt -falign-loops=4 -falign-jumps=4 -falign-functions=4 -march=pentium -mmmx -msse
while it should have been

Code:

-O3 -fomit-frame-pointer -ffast-math -fexpensive-optimizations -fstrict-aliasing -funroll-loops -funroll-all-loops -fforce-addr -finline-functions -frerun-loop-opt -falign-loops=4 -falign-jumps=4 -falign-functions=4 -march=athlon -mmmx -msse -m3dnow
Maybe this is what is going on there? I. e. a binary optimised for a different processor than the one you have?

ligang 04-22-2010 10:05 PM

i use "file" command to check two executable files:
Code:

[root@localhost boa]#file boa

boa: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0,dynamically linked (uses shared libs), stripped

[root@localhost nfs]# file appweb

appweb: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3,dynamically linked (uses shared libs), stripped

i found the difference that one is GNU/Linux 2.0.0, the other one is GNU/Linux 2.4.3. And the former one can run in my board, but the latter produce "illegal instruction". So what's the meanning of GNU/Linux 2.0.0. it refers to what version? Thanks!!!

nini09 04-23-2010 02:55 PM

This is GNU or GCC version for Linux.

FemtoLinux 04-27-2010 04:45 PM

Short answer - you are using a wrong toolchain, i.e. not the one that was used to compile your kernel and all the working applications.

Do you have the toolchain that came with this board ?

ligang 04-27-2010 11:13 PM

Quote:

Originally Posted by FemtoLinux (Post 3949768)
Short answer - you are using a wrong toolchain, i.e. not the one that was used to compile your kernel and all the working applications.

Do you have the toolchain that came with this board ?

Thanks for your reply! Yes, i have the toolchain that came with the board, however, that problem is still existing.

FemtoLinux 04-28-2010 01:43 AM

Are sure you use the same toolchain to compile both boa and appweb applications ? Same include path ?

FemtoLinux 04-28-2010 06:50 AM

It would also help if you could run "bt" in the gdb, to show us the exact line number of the problematic code

ligang 05-03-2010 02:30 AM

Floating point divide by zero
 
i have used gdb to debug my code. The reason it is crashing is a floating point divide by zero. The result should be NaN (or Infinity). It should not throw an exception. So, how to get this working.
My test code:
Code:

#include <stdio.h>

int main() {

double a, b;

a=1.0;

printf("BEFORE\n");

b=0.0;

a=a/b;

printf("Result %5.2f\n",a);

The result is:
Code:

BEFORE

Illegal instruction

The actual mistake code:
Code:

Program received signal SIGILL, Illegal instruction.
0x00099a30 in ejsCreateNumberType (ejs=0x1baf10) at ejsLib.c:8753
8753        ejs->infinityValue->value = 1.0 / zero;
(gdb) bt
#0  0x00099a30 in ejsCreateNumberType (ejs=0x1baf10) at ejsLib.c:8753
#1  0x000d5990 in createTypes (ejs=0x1baf10) at ejsLib.c:30934
#2  0x000d6050 in defineTypes (ejs=0x1baf10) at ejsLib.c:31127
#3  0x000d56e0 in ejsCreate (ctx=0x1bac60, master=0x0,
    searchPath=0x1bad28 "/mnt/jffs2/appweb/src/lib/appweb/bin/modules",
    flags=32) at ejsLib.c:30852
#4  0x000dd0d4 in ejsOpenWebFramework (control=0x1bab38, useMaster=1)
    at ejsLib.c:33936
#5  0x00035978 in maEjsHandlerInit (http=0x1b8b80, path=0x0) at ejsAppweb.c:867
#6  0x00018658 in maLoadStaticModules (http=0x1b8b80) at link.c:38
#7  0x00010f40 in maCreateServer (http=0x1b8b80, name=0x181ff4 "default",
    root=0x181f8c ".", ipAddr=0x0, port=-1) at server.c:455
#8  0x0000bcec in main (argc=1, argv=0xbefc7c64) at appweb.c:233


FemtoLinux 05-04-2010 01:59 AM

Try -msoft-float

nini09 05-04-2010 03:44 PM

The error code sent from kernel has limit reason, it hasn't NaN code.

ligang 05-04-2010 11:30 PM

Quote:

Originally Posted by nini09 (Post 3957331)
The error code sent from kernel has limit reason, it hasn't NaN code.

You mean my kernal cannot recognize NaN code, so NaN code is seen as Illegal instruction. How can i deal with this problem? All linux kernal cannot recognize NaN code? Can i directly change 1.0/zero to a very very max value?
Thanks!

nini09 05-06-2010 02:24 PM

Although the kernel should recognize NaN code, the NaN code can't return back to user space.


All times are GMT -5. The time now is 05:03 AM.