Page 1 of 1

Segmentation fault on 1.teplate application

Posted: Thu Jan 12, 2017 12:04 pm
by vladog
Hello

I was trying to create web app communicating with client through ajax interface. It did not work and simplifying this I got to the basics of problem:

- I built the app 1.template from https://github.com/RedPitaya/RedPitaya/ ... 1.template
- I opened the app from browser on another comp (the app worked normally)
- I sent the request "/data" (http://192.168.1.75/data)
- I got

Code: Select all

{
    "app": { },
    "datasets": { },
    "status": "ERROR",
    "reason": "Application not loaded"
}
- In the time of "/data" request the following messages were written to /var/log/redpitaya_nginx/debug.log:

Code: Select all

2017/01/12 10:34:04 [alert] 3777#0: worker process 4791 exited on signal 11
2017/01/12 10:34:04 [error] 5208#0: *403 Application not loaded, client: 192.168.1.93, server: , request: "GET /data HTTP/1.1", host: "192.168.1.75"
2017/01/12 10:34:04 [alert] 5208#0: *403 the http output chain is empty, client: 192.168.1.93, server: , request: "GET /data HTTP/1.1", host: "192.168.1.75"
Signal 11 means segmentation fault - the result of unresolved references, memory overwrites... but in such elementary application it is hidden somewhere in the environment.

Has somebody any idea about the reason of the problem? Of course - it is possible to use websocket for client - server data exchange. Anyways, I do not like applications which crash from unknown reasons.

I am using RP image "red_pitaya_OS-v0.96-RC1-20-14_jul.img", all app builds where performed on RP device.

Thanks for help
Vlado

Re: Segmentation fault on 1.teplate application

Posted: Sat Jan 14, 2017 1:40 am
by Nils Roos
Hi,

I had a look over the 1.template application, and the problem is a bad interaction between the nginx bazaar plugin and the application.

The plugin calls the "int rp_get_signals(float ***s, int *sig_num, int *sig_len)" function with pointers to uninitialized variables sig_num and sig_len, and when the application returns a success (=0), the plugin assumes that sig_num and sig_len contain valid values.

But the template application returns success without setting these variables, so the plugin continues with the uninitialized (=random) values. This can lead to a SEGFAULT or other unexpected behaviour when you use the /data request.

When you change main.cpp with the following, it wont crash anymore.

Code: Select all

int rp_get_signals(float ***s, int *sig_num, int *sig_len)
{
    *sig_num=0;
    *sig_len=0;
    return 0;
}