Skip to content

Getting 'illegal instruction' error on armv6 #283

Description

@Cydox

I built io.js with the change #282 on armv6.
When running io.js i get an 'Illegal instruction' error. g++ and gcc are on version 4.8.3.
There where no errors while building. I don´t know what other information i could give you.
Just ask me for the information you need and i´ll post it.

Activity

  1. bnoordhuis commented on Jan 11, 2015

    @bnoordhuis
    Member

    There was an rpi thread on v8-users recently. I don't know if you were involved but it lists a few things you can try. If nothing else, can you post the output of backtrace and disassemble from gdb?

  2. Cydox commented on Jan 11, 2015

    @Cydox
    Author

    I saw another thread. I´m trying command line arguments from that one. But this will take some time since the Pi is slow(probably will take till tomorrow morning). When it works should I do a PR so it will print an error message if people don't use these options and add it to #282 ?

  3. bnoordhuis commented on Jan 11, 2015

    @bnoordhuis
    Member

    Yes, that would be great.

  4. bnoordhuis commented on Jan 11, 2015

    @bnoordhuis
    Member

    @Cydox How did it work?

  5. fivdi commented on Jan 11, 2015

    @fivdi

    I remember having the 'illegal instruction' error on the Raspberry Pi after successfully compiling node v0.11.8 or v0.11.9 on the Pi itself. I think the issue may be related to the following code (from deps/v8/src/base/cpu.cc):

        // Unfortunately, it seems that certain ARMv6-based CPUs
        // report an incorrect architecture number of 7!
        //
        // See http://code.google.com/p/android/issues/detail?id=10812
        //
        // We try to correct this by looking at the 'elf_format'
        // field reported by the 'Processor' field, which is of the
        // form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for
        // an ARMv6-one. For example, the Raspberry Pi is one popular
        // ARMv6 device that reports architecture 7.
        if (architecture_ == 7) {
          char* processor = cpu_info.ExtractField("Processor");
          if (HasListItem(processor, "(v6l)")) {
            architecture_ = 6;
          }
          delete[] processor;
        }

    This code looks at the Processor field in file /proc/cpuinfo to see if it can find "(v6l)"

    Everything works correctly on older versions of Raspbian with the following /proc/cpuinfo as the Processor field contains "(v6l)":

    Processor   : ARMv6-compatible processor rev 7 (v6l)
    BogoMIPS    : 697.95
    Features    : swp half thumb fastmult vfp edsp java tls 
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant : 0x0
    CPU part    : 0xb76
    CPU revision    : 7
    
    Hardware    : BCM2708
    Revision    : 0002
    Serial      : 000000008a51a472
    

    However, on newer versions of Raspbian "(v6l)" has been moved to the model name field, V8 doesn't find it, and assumes that the Pi has an ARMv7 processor:

    processor   : 0
    model name  : ARMv6-compatible processor rev 7 (v6l)
    BogoMIPS    : 2.00
    Features    : swp half thumb fastmult vfp edsp java tls 
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant : 0x0
    CPU part    : 0xb76
    CPU revision    : 7
    
    Hardware    : BCM2708
    Revision    : 0002
    Serial      : 000000008a51a472
    

    Related issues:
    nodejs/node-v0.x-archive#7222
    https://code.google.com/p/v8/issues/detail?id=3112

  6. Cydox commented on Jan 12, 2015

    @Cydox
    Author

    This is really getting crazy now. An hour ago it the build on my Pi worked, but now i was giving it a second test but this time it gives me 'illegal instruction'. Runnig iojs --v8-options gives me

    target arm v6 vfp3 hard ARMv7=1 VFP3=1 VFP32DREGS=1 NEON=0 SUDIV=0 UNALIGNED_ACCESSES=1 MOVW_MOVT_IMMEDIATE_LOADS=0 COHERENT_CACHE=0 USE_EABI_HARDFLOAT=1

    so it is detecting armv7 again.
    @bnoordhuis should we try to change the code in cpu.cc? Or is it a problem because it is in v8?

  7. Cydox commented on Jan 12, 2015

    @Cydox
    Author

    i think the reason why it didnt work is that
    (as stated in https://code.google.com/p/v8/issues/detail?id=3112) the option arm-version=6
    I was using is not in this version of v8 but in a newer one. And in
    https://code.google.com/p/v8/issues/detail?id=3112 at the end there is a patch that
    looks like it should work(obviously I dont have enough experience with a code working on
    mutiple platforms). I´m gonna test the patch on my Pi and tell you wther it worked or not(and i´ll
    try more then once now before saying it works).

  8. Cydox commented on Jan 12, 2015

    @Cydox
    Author

    I added this change to the Code:

    if (architecture_ == 7) {
           std::cout << "7" << std::endl;
           char* processor;
           processor = cpu_info.ExtractField("Processor");
           if (HasListItem(processor, "(v6l)")) {
             architecture_ = 6;
           }
           processor = cpu_info.ExtractField("model name");
          if (HasListItem(processor, "(v6l)")) {
            std::cout << "6" << std::endl;
            architecture_ = 6;
          }
          delete[] processor;
        }
      }

    I included iostream obviously and added the 'print' statements to see wether thoughs if statements
    got called('not the best debugging probably'). Both if statements were called. ´So the architectue_
    should have been set to 6 just like it needs to. But the output is just:

    # ./iojs
    7
    6
    Illegal instruction
    

    I only did a short make so i didn´t need to compile the whole thing again. Could this have an
    impact? I can´t think of anything else. iojs --v8-options returned that it is armv7 again.

  9. Cydox commented on Jan 12, 2015

    @Cydox
    Author

    gdb backtrace and disassemble:

    gdb ./iojs
    GNU gdb (GDB) 7.4.1-debian
    Copyright (C) 2012 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "arm-linux-gnueabihf".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /home/pi/io.js/iojs...done.
    (gdb) run
    Starting program: /home/pi/io.js/iojs
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
    
    Program received signal SIGILL, Illegal instruction.
    0x00378a60 in _armv7_neon_probe ()
    (gdb) backtrace
    #0  0x00378a60 in _armv7_neon_probe ()
    #1  0x00232cc0 in OPENSSL_cpuid_setup ()
    #2  0x008a71d4 in __libc_csu_init ()
    #3  0xb6cc5228 in __libc_start_main () from /lib/arm-linux-gnueabihf/libc.so.6
    #4  0x00233068 in _start ()
    (gdb) dissasemble
    Undefined command: "dissasemble".  Try "help".
    (gdb) disassemble
    Dump of assembler code for function _armv7_neon_probe:
    => 0x00378a60 <+0>:     vorr    q15, q15, q15
       0x00378a64 <+4>:     bx      lr
    End of assembler dump.
    
  10. indutny commented on Jan 12, 2015

    @indutny
    Member

    @Cydox please type c and hit Enter key after seeing this openssl thing. It is the way the OpenSSL detects platform. It sets SIGILL handler and executes the assembly code.

    Again, this could be ignored, please hit the c after it.

  11. Cydox commented on Jan 12, 2015

    @Cydox
    Author

    like that?

    (gdb) run
    Starting program: /home/pi/io.js/iojs
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
    
    Program received signal SIGILL, Illegal instruction.
    0x00378a60 in _armv7_neon_probe ()
    (gdb) backtrace
    #0  0x00378a60 in _armv7_neon_probe ()
    #1  0x00232cc0 in OPENSSL_cpuid_setup ()
    #2  0x008a71d4 in __libc_csu_init ()
    #3  0xb6cc5228 in __libc_start_main () from /lib/arm-linux-gnueabihf/libc.so.6
    #4  0x00233068 in _start ()
    (gdb) c
    Continuing.
    
    Program received signal SIGILL, Illegal instruction.
    0x00378a68 in _armv7_tick ()
    
  12. indutny commented on Jan 12, 2015

    @indutny
    Member

    What if you'll hit c again? ;)

  13. Cydox commented on Jan 12, 2015

    @Cydox
    Author

    here are a bunch of ´em :D

     c
    Continuing.
    
    Program received signal SIGILL, Illegal instruction.
    0x00378a68 in _armv7_tick ()
    (gdb) c
    Continuing.
    [New Thread 0xb6cab450 (LWP 26581)]
    [New Thread 0xb64ab450 (LWP 26582)]
    [New Thread 0xb5cab450 (LWP 26583)]
    [New Thread 0xb54ab450 (LWP 26584)]
    7
    6
    
    Program received signal SIGILL, Illegal instruction.
    0x539242c0 in ?? ()
    (gdb) c
    Continuing.
    [Thread 0xb54ab450 (LWP 26584) exited]
    [Thread 0xb5cab450 (LWP 26583) exited]
    [Thread 0xb64ab450 (LWP 26582) exited]
    [Thread 0xb6cab450 (LWP 26581) exited]
    
    Program terminated with signal SIGILL, Illegal instruction.
    The program no longer exists.
    
  14. Cydox commented on Jan 14, 2015

    @Cydox
    Author

    Any new ideas on what fails here?

  15. bnoordhuis commented on Jan 14, 2015

    @bnoordhuis
    Member

    It's most likely the last SIGILL that we're interested in. If all else fails, turn on coredumps with ulimit -c and disassemble it in gdb afterwards: gdb /path/to/iojs /path/to/corefile, then disassemble. Maybe inspect info threads as well (help threads for more info, or ask if you have questions.)

  16. 44 remaining items

  17. rvagg commented on Jan 22, 2015

    @rvagg
    Member

    Woohoo! Great work everyone!

  18. indutny commented on Jan 22, 2015

    @indutny
    Member

    thanks everyone!

  19. SynerG commented on Jan 26, 2015

    @SynerG

    Awesome work, thank you!
    Please, take into account that armv6 is still not compiled by the CI, so armv6 builds are not available for download.
    It would be great if you consider to include the appropriate configuration in Jenkins.
    Armv6 is probably one of the worst targets to be built locally as hardware such as Raspberry Pi is extremely slow and some distributions don't even have gcc/g++ > 4.8, so users would really appreciate a precompiled package. Thanks!

  20. rvagg commented on Jan 26, 2015

    @rvagg
    Member

    @SynerG yes this is on my list of things to do very soon, the real hassle is getting a good setup for doing builds with Raspbian Wheezy as lowest-common-denominator platform, of course gcc is the problem there.

  21. SynerG commented on Jan 27, 2015

    @SynerG

    @rvagg thank you for working on the issue.
    I have no previous experience setting up a cross-compilation environment for armv6, but maybe the tips here could be useful:
    https://aabdelfattah.wordpress.com/2014/03/08/cross-compiling-a-pie-the-raspberry-pi-ultimate-guide/

    In case it is of any help, I have just built io.js directly on my RPi using Xbian (based on Raspbian Wheezy).
    The stock gcc was 4.6.x.
    Using Wheezy repo, I was able to install gcc/g++ 4.8.2 (by doing: sudo apt-get install -y gcc-4.8 g++-4.8)
    Using Jessie repo, the gcc/g++ version installed was 4.8.3.
    Compilation on the Rpi took over 7 hours using gcc 4.8.3.
    io.js --version states v1.0.5 and my app which uses some ES6 features seems to be working properly ;)

  22. rvagg commented on Jan 27, 2015

    @rvagg
    Member

    FYI, this is pretty good, only 12 failures on a pi, mostly timeouts I suspect: https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/118/nodes=iojs-armv6-raspbian-wheezy/console

    Also attempting a nightly: https://jenkins-iojs.nodesource.com/job/iojs+release+nightly/68/nodes=iojs-armv6-raspbian-wheezy/console

    It's all very slow of course because it's native, but I'm hoping that ccache will make this more reasonable to include as a regular test target and build target. Time will tell.

  23. silverwind commented on Feb 3, 2015

    @silverwind
    Contributor

    @rvagg I think we can close this issue as solved. I looked through the current test failures and they all seem to be various timeouts, nothing serious.

  24. rvagg commented on Feb 3, 2015

    @rvagg
    Member

    @silverwind agreed; I did start work on a "very-slow" flag for the test builds so that when you're running the test suite on armv6, various tests can choose to extend their timeouts and time expectations, just so we can get past them. In one instance there, the max time expected is 1s but it's taking above 6s on a RPi. Process startup is particularly slow which is a big problem for the test suite.

  25. magic890 commented on Jul 3, 2015

    @magic890

    Here is the official patch from V8 team: https://github.com/v8/v8-git-mirror/blob/master/src/base/cpu.cc#L483-L499

    I have created a pull request to solve this issue: #25625

  26. added
    armIssues and PRs related to the ARM architecture.
    on Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    armIssues and PRs related to the ARM architecture.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions