SIGILL, Illegal instruction. OPENSSL_cpuid_setup () ARM7 raspberry pi 2[SOLVED]

Hi:

I did a upgrade on raspberry pi2, and now mi program crashed,
this app is a Image Slideshow, which use shaders for the transitions, so the app only pass to the shaders de progress uniform and the textures. This app works fine on raspberry pi B+, but in the new Raspberry pi 2, this compile but crash whe i run that. the openframeworks i used is the 0.8.4 for armv7. the examples run well (gles folder, running the customEGLWindowSettings and others).

this is the output

notice ] ofAppEGLWindow: setupRPiNativeWindow(): screenRect: 1920x1080
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): windowRect: 1920x1080
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
[notice ] ofAppEGLWindow: createSurface(): EGL Display correctly set
[notice ] ofAppEGLWindow: createSurface(): current renderer type: ProgrammableGL
[notice ] ofAppEGLWindow: createSurface(): GLES2 renderer detected
[notice ] ofAppEGLWindow: createSurface(): surface created correctly
[notice ] ofAppEGLWindow: createSurface(): API bound correctly
[notice ] ofAppEGLWindow: createSurface(): -----EGL-----
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MAJOR = 1
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MINOR = 4
[notice ] ofAppEGLWindow: createSurface(): EGL_CLIENT_APIS = OpenGL_ES OpenVG
[notice ] ofAppEGLWindow: createSurface(): EGL_VENDOR = Broadcom
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION = 1.4
[notice ] ofAppEGLWindow: createSurface(): EGL_EXTENSIONS = EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_vg_parent_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_lock_surface
[notice ] ofAppEGLWindow: createSurface(): GL_RENDERER = VideoCore IV HW
[notice ] ofAppEGLWindow: createSurface(): GL_VERSION = OpenGL ES 2.0
[notice ] ofAppEGLWindow: createSurface(): GL_VENDOR = Broadcom
[notice ] ofAppEGLWindow: createSurface(): -------------
[ error ] ofShader: begin(): couldn’t begin, shader not loaded
[ error ] ofShader: begin(): couldn’t begin, shader not loaded
[ error ] ofShader: begin(): couldn’t begin, shader not loaded
[ error ] ofShader: begin(): couldn’t begin, shader not loaded
[notice ] ofAppEGLWindow: setupPeripherals(): peripheral setup complete
[notice ] ofAppEGLWindow: setupNativeUDev(): created udev object
[notice ] ofAppEGLWindow: setupMouse(): unabled to find mouse
[ error ] ofAppEGLWindow: setupMouse(): did not open mouse
[ error ] ofAppEGLWindow: setupMouse(): did not open mouse, mouse_fd < 0
[warning] ofAppEGLWindow: setupKeyboard(): unabled to find keyboard
[ error ] ofAppEGLWindow: setupKeyboard(): did not open keyboard
[ error ] ofAppEGLWindow: setupKeyboard(): did not open keyboard, keyboard_fd < 0
[notice ] ofAppEGLWindow: setupPeripherals(): native event setup complete
[notice ] ofAppEGLWindow: setupOpenGL(): peripheral setup complete
[warning] ofShader: GL_VERTEX_SHADER shader reports:
Compiled
[warning] ofShader: GL_FRAGMENT_SHADER shader reports:
Compiled
[notice ] ofAppEGLWindow: runAppViaInfiniteLoop(): entering infinite loop
terminate called after throwing an instance of ‘J_MESSAGE_CODE’
[notice ] ofAppEGLWindow: destroyNativeKeyboard()
[notice ] ofAppEGLWindow: destroyNativeKeyboard(): unable to reset terminal
[notice ] ofAppEGLWindow: destroySurface(): destroying EGL surface

header:

Below the ofApp.cpp code:

#include "ofApp.h"
int x2;
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetFrameRate(25);
        ofHideCursor();
        x2 = 1;
        ofEnableAlphaBlending();
        n = dir.listDir("imgs");
        seq.resize( n );
        //im.loadImage("betho.jpg");
        //4. Load images
        for (int i=0; i<n; i++) {
                //Getting i-th file name
                string fileName = dir.getPath( i );

                //Load i-th image
                ofLoadImage( seq[i], fileName );
                //seq[i].resize(1920,1080);
        }
        shader.load("shader.vert", "shader.frag", "");
        fbo.allocate(ofGetWidth(), ofGetHeight());

        //ofEnableAlphaBlending();
}

//--------------------------------------------------------------
void ofApp::update(){
    n1 = dir.listDir("/home/pi/imgs");
    if(!(n==n1)){
        seq.resize( n1 );
        for (int i=0; i<n1; i++) {
                string fileName = dir.getPath( i );
                ofLoadImage( seq[i], fileName );
                //seq[i].resize(1920, 1080);
        }
    //cout<<"n=" << n <<endl;
    //cout<<"n1=" << n1 <<endl;
        n=n1;
    }

        y=ofGetFrameNum();
        time1 = (y%201);
        switch(time1)
        {
        case 0:
                if(x2==n) {
                        x2=0;
                        x++;
                }
                else if(x2<n){
                        x2++;
                        x=x2-1;
                        }
                break;
        default:
                break;
        }
        progress=ofMap(time1,0,25,0,1,true);
        //seq[x];
        //seq[x2];
        fbo.begin();
                ofBackground(0);
                shader.begin();
                        shader.setUniform2f("resolution", ofGetWidth(), ofGetHeight());
                        //shader.setUniform1f("time", ofGetElapsedTimef());
                        shader.setUniform1f("progress", progress);
                        shader.setUniformTexture("from", seq[x],1);
                        shader.setUniformTexture("to", seq[x2],2);
                        //shader.setUniformTexture("luma", im,3);
                        //img.draw(0,0);
                        ofRect(0,0,1920,1080);
                shader.end();
        fbo.end();
        //std::stringstream pro;
        //pro <<ofToString(time1);
        //ofSetWindowTitle(pro.str()); 
}
//--------------------------------------------------------------
void ofApp::draw(){
        fbo.draw(0,0);
}

##############################################################################################

here the header

> #pragma once

#include "ofMain.h"

class ofApp : public ofBaseApp{

        public:
                void setup();
                void update();
                void draw();
                ofDirectory dir;
                int n;
                int n1;
                int x,y,time1;
        float progress;
        ofTexture img;
        ofTexture img2;
                ofShader shader;
                ofFbo fbo;
        vector<ofTexture> seq;
                void keyPressed(int key);
                void keyReleased(int key);
                void mouseMoved(int x, int y );
                void mouseDragged(int x, int y, int button);
                void mousePressed(int x, int y, int button);
                void mouseReleased(int x, int y, int button);
                void windowResized(int w, int h);
                void dragEvent(ofDragInfo dragInfo);
                void gotMessage(ofMessage msg);
};

the main file:

#include "ofMain.h"
#include "ofApp.h"
#ifdef TARGET_OPENGLES
#include "ofGLProgrammableRenderer.h"
#endif
//========================================================================
int main( ){
        #ifdef TARGET_OPENGLES
        ofSetCurrentRenderer(ofPtr<ofBaseRenderer>(new ofGLProgrammableRenderer()));
        #endif
        ofSetupOpenGL(1920,1080, OF_WINDOW);
        // this kicks off the running of my app
        // can be OF_WINDOW or OF_FULLSCREEN
        // pass in width and height too:
        ofRunApp(new ofApp());

}

whats is the meaning of “terminate called after throwing an instance of ‘J_MESSAGE_CODE’” ?/

with gdb (GNU debugger) I got the follow:

Program received signal SIGILL, Illegal instruction.
0x76d80608 in ?? () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0
(gdb) bt
#0  0x76d80608 in ?? () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0
Cannot access memory at address 0x0
#1  0x76d7d004 in OPENSSL_cpuid_setup () from /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0
#2  0x76fe8254 in ?? () from /lib/ld-linux-armhf.so.3
#3  0x7efff7f4 in ?? ()
Cannot access memory at address 0x0
#4  0x7efff7f4 in ?? ()
Cannot access memory at address 0x0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

it is a bug???
What thing am I doing wrong??

someone ??

I’m having the exact same problem when porting an app that works on OSX to raspberry PI 2. I’m completely out of my element debugging this kind of error, so any help would be appreciated!

are you using 0.8.4? in that case try with 0.9

Thanks for the quick response!

I’m running on a newly installed raspberry pi 2 (raspbian jessie) with v20151003 nightly openframeworks build for arm7 (mostly following the instructions from Raspberry Pi 2 Setup Guide (0.8.4). Specifically building with MAKEFLAGS=-j4 PLATFORM_VARIANT=rpi2 make and running with make run.

After I posted, I tried getting with an example (graphics/polygon) – that worked. I’m going to try a couple other examples (specifically image/video since that’s the bulk of what my app is using) before coming back to my app. I’ll let you know if I get anywhere.

Thanks!

illegal instruction usually means that some library has symbols compiled with some optimization that is not present in the current cpu, for example in arm if it’s compiled with neon but the cpu doesn’t support neon extensions. we use openssl from the system so it might be that the openssl library that raspbian includes has some problem with the rpi2 cpu.

is this happening when loading some resource from the web?

Ok, it looks like the SIGILL is a red-herring for my particular problem. There was a bug with how I was running my app resulting in an early exit (with no console output). When I pass the right arguments it all works properly (time to add some better error logging).

As for the SIGILL, that error shows up even when running an example under gdb from the pi (polygonExample is what I tried). More specifically, gdb breaks at the SIGILL, but if you continue things work fine. That is either a bug or intended behavior of OpenSSL on the pi, but it only is a minor irritation when using gdb AFAICT.

Thanks again!

Later I discovered that the error was caused by the very long name of the images, the secretary upload this images to the sitie for the slideshow… these were updated in each update cycle. so that, by reducing the length of the images name, the app running fine. curiously at the RPI b + what was happening with the long name of the images was not displayed, but the program never ended with this error

Thanks.

ah yes - it is pretty annoying

You can still use gdb if you enter this before running your app

handle SIGILL nostop
handle SIGINT nostop

gdb will complain but still be able to work

1 Like

Thanks jcleave