【发布时间】:2017-05-09 06:13:57
【问题描述】:
我在基于 ARM 的板上运行以下代码:
void MainLoop()
{
char command[256];
int ret = 0;
int loopCount = 0;
while(1)
{
memset(command, '\0', sizeof(command));
sprintf(command, "/usr/bin/gst-launch-0.10 imxv4l2src ! imxv4l2sink &");
ret = system(command);
printf("StartStreamer: command=[%s], status:%d\n", command, ret);
if ( ret != 0 )
{
ret = system("reboot");
printf("Rebooting:%d\n", ret);
}
sleep(15);
memset(command, '\0', sizeof(command));
sprintf(command, "killall gst-launch-0.10");
ret = system(command);
printf("StopStreamer: command=[%s], status = %d\n", command, ret);
if ( ret != 0 )
{
ret = system("reboot");
printf("Rebooting:%d\n", ret);
}
sleep(15);
loopCount++;
printf("Loop Count:%d\n", loopCount);
}
}
运行一些随机循环后,我收到以下错误:
sh: out of memory
StartStreamer: command=[/usr/bin/gst-launch-0.10 imxv4l2src ! imxv4l2sink &], status:256
Segmentation fault
Rebooting:35584
StopStreamer: command=[killall gst-launch-0.10], status = 11
Rebooting:11
Loop Count:26
sh: relocation error: sh: symbol free, version GLIBC_2.4 not defined in file libc.so.6 with link time reference
sh: relocation error: sh: symbol free, version GLIBC_2.4 not defined in file libc.so.6 with link time reference
StartStreamer: command=[/usr/bin/gst-launch-0.10 imxv4l2src ! imxv4l2sink &], status:32512
Rebooting:11
killall: gst-launch-0.10: no process killed
StopStreamer: command=[killall gst-launch-0.10], status = 11
Rebooting:11
Loop Count:27
StartStreamer: command=[/usr/bin/gst-launch-0.10 imxv4l2src ! imxv4l2sink &], status:32512
Rebooting:32512
你能告诉我“sh:Out of Memory”是什么意思吗,是因为系统调用太多吗?另外,我在glibc中出现重定位错误很奇怪……
我已经从 C 应用程序修改为 Bash 脚本:
#!/bin/ash
count=0
while [ true ];do
echo "Starting Streamer"
/usr/bin/gst-launch-0.10 imxv4l2src ! imxv4l2sink &
sleep 15
echo "Stopping Streamer"
killall gst-launch-0.10
sleep 15
count=$((count+1))
echo $count
done
在运行一些循环后,我得到以下错误:
* /bin/sh': double free or corruption (out): 0x0028ebf8 ***
*** Error in/bin/sh' 中的错误:malloc():内存损坏:0x0028edf8 *
【问题讨论】:
-
如果不是您的程序滥用内存,那么它一定是您启动的程序之一导致主板内存不足。
-
你能告诉我检查程序内存使用的命令吗
标签: c linux segmentation-fault arm sh