LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 04-20-2010, 12:30 AM   #1
ligang
LQ Newbie
 
Registered: Apr 2010
Posts: 13

Rep: Reputation: 1
Unhappy 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     }
 
Old 04-21-2010, 06:22 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
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?
 
Old 04-22-2010, 10:05 PM   #3
ligang
LQ Newbie
 
Registered: Apr 2010
Posts: 13

Original Poster
Rep: Reputation: 1
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!!!
 
Old 04-23-2010, 02:55 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
This is GNU or GCC version for Linux.
 
Old 04-27-2010, 04:45 PM   #5
FemtoLinux
LQ Newbie
 
Registered: Apr 2010
Posts: 11

Rep: Reputation: 0
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 ?
 
Old 04-27-2010, 11:13 PM   #6
ligang
LQ Newbie
 
Registered: Apr 2010
Posts: 13

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by FemtoLinux View Post
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.
 
Old 04-28-2010, 01:43 AM   #7
FemtoLinux
LQ Newbie
 
Registered: Apr 2010
Posts: 11

Rep: Reputation: 0
Are sure you use the same toolchain to compile both boa and appweb applications ? Same include path ?
 
Old 04-28-2010, 06:50 AM   #8
FemtoLinux
LQ Newbie
 
Registered: Apr 2010
Posts: 11

Rep: Reputation: 0
It would also help if you could run "bt" in the gdb, to show us the exact line number of the problematic code
 
Old 05-03-2010, 02:30 AM   #9
ligang
LQ Newbie
 
Registered: Apr 2010
Posts: 13

Original Poster
Rep: Reputation: 1
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

Last edited by ligang; 05-03-2010 at 03:10 AM.
 
Old 05-04-2010, 01:59 AM   #10
FemtoLinux
LQ Newbie
 
Registered: Apr 2010
Posts: 11

Rep: Reputation: 0
Try -msoft-float
 
Old 05-04-2010, 03:44 PM   #11
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
The error code sent from kernel has limit reason, it hasn't NaN code.
 
Old 05-04-2010, 11:30 PM   #12
ligang
LQ Newbie
 
Registered: Apr 2010
Posts: 13

Original Poster
Rep: Reputation: 1
Smile

Quote:
Originally Posted by nini09 View Post
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!
 
Old 05-06-2010, 02:24 PM   #13
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Illegal instruction (core dumped) giancarlo76 Linux - Desktop 0 12-26-2006 09:06 AM
aticonfig illegal instruction tamtam Slackware 14 09-22-2006 08:27 PM
MPlex - Illegal Instruction RySk8er30 Linux - Software 1 01-22-2006 12:50 PM
Chroot problems in Gentoo 1.4: Illegal Instruction KneeLess Linux - Distributions 4 11-13-2003 09:44 PM
Illegal instruction madsjakob Linux - Software 0 10-28-2003 07:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration