- 論壇徽章:
- 0
|
20可用積分
在ARM7+uClinux-2.4.20上調(diào)我們下面這個(gè)應(yīng)用程序時(shí),經(jīng)常會(huì)報(bào)fault-common.c 387這個(gè)錯(cuò)誤。只有堆棧溢出導(dǎo)致內(nèi)核拋出fault-common.c 387這個(gè)錯(cuò)誤嗎?如果確實(shí)是這樣,實(shí)在想不通下面這種情況:
我們的一個(gè)應(yīng)用程序netrouter會(huì)在函數(shù)里調(diào)用一個(gè)腳本(gprs-start)來運(yùn)行pppd,進(jìn)行GPRS撥號(hào)上網(wǎng)。
1,如果我只運(yùn)行netrouter,而不讓netrouter啟動(dòng)pppd,系統(tǒng)運(yùn)行很正常,內(nèi)核不會(huì)報(bào)這個(gè)error;-> netrouter應(yīng)該沒問題
2,如果不運(yùn)行netrouter,手動(dòng)啟動(dòng)pppd,系統(tǒng)運(yùn)行也很正常;-> pppd從官方下了交叉編譯的,這里也沒報(bào)堆棧溢出錯(cuò)誤;
3,如果我使用netrouter來運(yùn)行pppd,則內(nèi)核會(huì)報(bào)fault-common.c 387, 并拋出Oops;
fault-common.c 387
fault-common.c 387
fault-common.c 387
Unhandled fault: alignment exception (13) at 0x00000001
fault-common.c(97): start_code=0x2f00040, start_stack=0x2fffed
Internal error: Oops: 0
CPU: 0
pc : [<000314d4>] lr : [<00ceb040>] Not tainted
sp : 02e67ed4 ip : 65523c20 fp : 02e67ef0
r10: 02e67f64 r9 : 00000066 r8 : 00000000
r7 : 000001f0 r6 : 007ab9a4 r5 : 40000013 r4 : 007ab99c
r3 : 696b6f50 r2 : 9617a0c0 r1 : 000001f0 r0 : 007ab99c
Flags: nzCv IRQs off FIQs on Mode SVC_32 Segment kernel
Control: 0
Process pppd (pid: 99, stackpage=02e67000)
Stack:
02e67ec0: 00ceb040 000314d4 20000093 ffffffff 00000001 00c1a730 00000001
02e67ee0: 001cd364 02e67f0c 02e67ef4 000fb1b4 00031488 001a620c 00c1a730 00000002
02e67f00: 02e67f28 02e67f10 001566a0 000fb1a0 00c1a730 00000004 00000002 02e67f38
02e67f20: 02e67f2c 001567b8 00156674 02e67f60 02e67f3c 000f9910 00156780 00000000
02e67f40: 02f2fa84 00000009 02e66000 00019700 02f38924 02e67f78 02e67f64 000f9988
02e67f60: 000f9898 0000000c 00000000 02e67fac 02e67f7c 000fa574 000f9980 00000000
02e67f80: 00000000 00000001 00000002 00000000 02e66000 00019700 0000005a 00000018
02e67fa0: 00000000 02e67fb0 00019560 000fa4e8 00000018 0001eee0 00000001 02fffe10
02e67fc0: 00000000 00000001 00000018 02f2fa84 00000009 00000002 00000007 00000000
02e67fe0: 02f38924 02fffe0c 02fffe10 02fffdfc 02f29a34 02f2b0cc 20000010 00000001
Backtrace:
netrouter啟動(dòng)pppd的程序流程大致如下:
- pacArgv [0] = "/etc/ppp/gprs-start";
- pacArgv [1] = (CFG_PPP_AUTH_TYPE_CHAP == pstSIM->ucAuth) ? "CHAP" : "PAP";
- pacArgv [2] = pstSIM->acAPN;
- pacArgv [3] = pstSIM->acUID;
- pacArgv [4] = pstSIM->acPWD;
- pacArgv [5] = pstSIM->acIP;
- pacArgv [6] = 0;
-
- ucRet = mod_ppp_script (p_pstPPP, pacArgv [0], pacArgv, 60000, 0x00);
復(fù)制代碼
mod_ppp_script()函數(shù)啟動(dòng)pppd大致如下:
- stChildPid = vfork ();
- switch (stChildPid)
- {
- case 0: // Child
- // Set a new group ID
- setpgid (stChildPid, stChildPid); //這里子進(jìn)程在父進(jìn)程的進(jìn)程空間里做什么事,不至于導(dǎo)致堆棧溢出
- execv (p_pcScript, p_pacArgv); //調(diào)execv后,子進(jìn)程在自己的進(jìn)程空間里來執(zhí)行shell腳本,應(yīng)該不會(huì)影響父進(jìn)程
- iRet = (0 != errno) ? errno : 1;
- ***
- case -1:
- ***
- default:
- ***
- }
復(fù)制代碼
在/etc/ppp/gprs-start腳本中或做一些解析,并啟動(dòng)pppd
- #!/bin/sh
- #
- GPRS_AUTH=$1
- GPRS_APN=$2
- GPRS_USERNAME=$3
- GPRS_PASSWORD=$4
- GPRS_IP_ADDR=$5
-
- export GPRS_APN
-
- if (test "CHAP" = "$GPRS_AUTH")
- then
- auth="/etc/ppp/gprs-chap"
- else
- auth="/etc/ppp/gprs-pap"
- fi
-
- if (test -n "$GPRS_USERNAME")
- then
- uid="user $GPRS_USERNAME"
- else
- uid="user none"
- fi
- if (test -n "$GPRS_PASSWORD")
- then
- pwd="password $GPRS_PASSWORD"
- else
- pwd="password none"
- fi
-
- if (test -n "$GPRS_IP_ADDR")
- then
- ip_addr="$GPRS_IP_ADDR:"
- else
- ip_addr=
- fi
-
- rm -f /tmp/ppp0.pid
- rm -f /tmp/LCK..ttyS1
- if (pppd file $auth $ip_addr $uid $pwd &) #這里啟動(dòng)pppd來進(jìn)行撥號(hào)上網(wǎng)
- then
- while (test 1 -eq 1)
- do
- if (pgrep -x pppd > /dev/null)
- then
- sleep 1
- else
- exit 1
- fi
-
- if (ifconfig ppp0 | grep "addr:" > /dev/null)
- then
- exit 0
- fi
- done
- fi
-
- exit 1
復(fù)制代碼
單獨(dú)運(yùn)行netrouter沒問題;應(yīng)該可以說明netrouter程序并不存在堆棧溢出;
單獨(dú)運(yùn)行pppd沒問題,應(yīng)該可以說明pppd程序也不存在堆棧溢出;
如果用netrouter來啟動(dòng)pppd程序,則內(nèi)核報(bào)了fault-common.c錯(cuò)誤,這是由于堆棧溢出引起的嗎?如果是的話,那在哪里溢出了?如果不是,那又是什么原因?qū)е耭ault-common.c錯(cuò)誤,并拋出Oops?
PS: 我也用arm-elf-flthdr工具將兩個(gè)程序(netrouter和pppd)的棧調(diào)到256K,512K試過,但都會(huì)出現(xiàn)上面這個(gè)問題。 |
最佳答案
查看完整內(nèi)容
LZ, 請(qǐng)把編譯選項(xiàng)貼出來. 可能是pic選項(xiàng)的問題.例: # CFLAGS="$CFLAGS -D__PIC__ -fpic -msingle-pic-base" CFLAGS="$CFLAGS -D__PIC__ -fno-pic -fno-PIC"[ 本帖最后由 yidou 于 2009-3-24 11:52 編輯 ]
|