0

I have a custom petalinux 2016.3 system running and observe the following: When I compile and run a cpp that uses system() calls like the example under i get:

Oops: kernel access of bad area, sig: 11
CPU: 0 PID: 381 Comm: Application Not tainted 4.6.0 #63
task: ce486500 ti: ce4cc000 task.ti: ce4cc000

I can see all 3 echos in the terminal, but the Oops appears before the "we never get here" printf. It seems like the kernel access of bad area appears when function() returns.

Are there some specific kernel or rootfs modules/settings missing that could make the system behave this way?

I have several thousand lines of code running other library functions and it is only system() that seems to fail.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

using namespace std;

void function(){
  system("echo hello");
  system("echo hello2");
  system("echo hello3");
}

int main(int argc, char **argv){
  function();
  printf("We never get here\n");
  return 1;
}

After some more debugging, the problem seemed to come from a library included in the makefile (lEasyBmp).

Why it triggered this exact failure when not used I have not found out. All library files are built and found in the system but if anyone has the same problem, including some libraries might trigger it.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
btbtbt
  • 11
  • 2

3 Answers3

1

It seems like the problem was actually the system() function causing some very strange undefined behaviour. Putting them in a child like the following has solved the problem:

void forksystem(char* command){
    pid_t pid;
    int status = 0;
    pid = fork();
    if(pid == 0){
      system(command);
      exit(1);
    }
    wait(&status);
}
btbtbt
  • 11
  • 2
0

I think problem is with kernel you are working with.

I just ran same code in my ubuntu, It works fine.

Analyze the core file generated. kernel oops messages may contain necessary information. Also check whether there are any known issues with kernel version which you are using.

snagendr@SUPERMAN:~/C$ ./a.out 
hello
hello2
hello3
We never get here
sandeep nagendra
  • 422
  • 5
  • 15
0

Oops is a kernel print. Something in your kernel is not working well. Try to update it, than re-compile or, if you are cross compiling the application, your toolchain is not well configured for your system.

Seems that your MMU is not working well. Kernel try to access to a user space memory or to a un unmapped/reserved area.