cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
244 Views
Registered: ‎08-23-2018

Segmentation fault occurs when executing application after executing apache2 during Zynq booting

Hello,

I am using ZYNQ XC7Z020 custom board.

The kernel version is avnet-digilent-zedboard-2018_3.

When the apache2 daemon is executed during booting and then the application is immediately executed, a segmentation fault occurs.

SD card booting did not have this phenomenon, but it appeared after changing to emmc booting.

If sleep 3 is given before executing the application, a segmentation fault does not occur.

The program runs automatically in /etc/profile.

Why should I give sleep to work normally?

=> FAIL log

Starting web server: apache2.
Starting tcf-agent: OK
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

supervisor.sh: line 9: 1234 Segmentation fault /home/root/target_atsc_literx

 

=> PASS log

Starting web server: apache2.
Starting tcf-agent: OK
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

Last login: Wed Jul 15 07:05:09 UTC 2020 on tty1
sleep 3

start program...

 

Thank you.

Best regards.

Gyosun.

0 Kudos
4 Replies
Highlighted
Scholar
Scholar
223 Views
Registered: ‎05-28-2013

The application (target_atsc_literx) appears to have a dependency on something - perhaps Ethernet being up, or some other kernel driver, or possibly another application (eg background daemon). Adding "sleep 3" seems to avoid this problem, but this is not really a great solution.

It would be best to identify what the dependency is. You can do this by debugging the application, for example with gdb or strace. The most likely cause of the segmentation fault is failure to check the return code from system calls such as open(), mmap(), etc. Once you know what is failing, modify the application to deal with it more gracefully.

As for why the behaviour changed between SD and eMMC, my guess would be the boot speed for these differs. If it takes longer to boot on SD card, there may have been enough time for kernel driver to initialize before the application starts.

0 Kudos
Highlighted
144 Views
Registered: ‎08-23-2018

Hi Scholar,

 

Thank you for answer.

For testing purposes, the application was written simply.

There is nothing wrong with the program.

int main(){

while(1) usleep(100);

return 0;

}

SD card takes longer to boot up.

I don't understand that segment fault occurs when the program is executed during apache2 driver initialization.

If the apache2 driver takes a long time to initialize,

Is there any way to start the application naturally other than giving 3 seconds of sleep?

 

Thank you.

Best Regards.

Gyosun.

 

 

0 Kudos
Highlighted
Scholar
Scholar
137 Views
Registered: ‎05-28-2013


For testing purposes, the application was written simply.

There is nothing wrong with the program.

int main(){
    while(1) usleep(100);
    return 0;
}


Agreed, this is about as simple as you can get. I do not see how this could produce a segmentation fault, there are no allocations, no open files, no memory access at all.


SD card takes longer to boot up.

I don't understand that segment fault occurs when the program is executed during apache2 driver initialization.

I doubt that apache2 is causing the issue. It is a totally separate application. It just happens to be the last one started, so in the boot log, it appears right before your application.

To be sure, you could try disabling (or even removing) apache2, especially if you are not using it.

If the apache2 driver takes a long time to initialize,
Is there any way to start the application naturally other than giving 3 seconds of sleep?

Sorry I was not clear. I meant that the speed of SD and eMMC differ, so overall, the speed of the whole boot process will differ. For example if you measure how long it takes from power on, until Etheret port is functioning (link is up, etc), you may notice a difference between SD and eMMC. An application program which expects to read/write over Ethernet would fail (possibly with a segfault) if it tries to use Ethernet too soon.

You mentioned the application is stated in /etc/profile, this is a bit unusual. The /etc/profile script normally just sets up various parameters (like the PATH, umask, etc). It is not meant to start programs that continue running. Perahs consider starting your program using either sysvinit (/etc/init.d/programname) or systemd unit files (depending on which kind of init you are using)?

0 Kudos
Highlighted
127 Views
Registered: ‎08-23-2018

Thank you for quick response.

Since it uses web GUI, apache2 cannot be removed.

In addition to registering in the Profile, I created the /etc/init.d/startup file and created a link to /etc/rc5.d/S99xstartup and ran it.

As the application program runs, it occupies the CPU, and it is suspected that there is a problem with the initialization of the driver.

However, I couldn't find a clear solution other than giving 3 seconds of sleep.

Thank you,

Best Regards.

Gyosun.

 

0 Kudos