Hi, expert:
Recently, I encounter a tricky issue when using "aplay" to playback music on arm64 core, but "aplay" application and "alsa-lib" are 32 bit version. The exception happens and it results in "aplay" segment fault. I tried to root cause it thought adding some logs, but I don't catch it. Any suggestion will be appreciated! Thanks!
1. Aplay will call the "writei" function in alsa-lib. This function is used to transfer audio sample from user space to kernel space. It will be called many times. This issue maybe happened when calling this function at the first time. Or it happened at the second/third time.
static snd_pcm_sframes_t snd_pcm_hw_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
{
printf("writei++\n"); /*my log: this log is printed out*/
err = ioctl(fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &xferi);
printf("writei--, err=0x%x\n", err); /*my log: this log isn't printed out when issue happened*/
}
2. So the ioctl will trap into kernel function.
static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
{
case SNDRV_PCM_IOCTL_WRITEI_FRAMES32:
printk("======snd_pcm_ioctl_compat11\n");
return snd_pcm_ioctl_xferi_compat(substream, SNDRV_PCM_STREAM_PLAYBACK, argp); /*I checked this function, and it is retuned with the correct value*/
}
3. Exception happens. And the log is as the following.
writei++
[ 39.752267] 832 (aplay) ======snd_pcm_ioctl_compat++++++++
[ 39.760480] 832 (aplay) ======snd_pcm_ioctl_compat11
[ 39.767334] 832 (aplay) ========snd_pcm_ioctl_xferi_compat++++
[ 39.899134] 832 (aplay) ========snd_pcm_ioctl_xferi_compat------
[ 39.907413] 832 (aplay) Bad mode in Error handler detected, code 0xbf000000
[ 39.916944] 832 (aplay) CPU: 0 PID: 832 Comm: aplay Not tainted 3.10.0+ #64
[ 39.926508] 832 (aplay) task: ffffffc000861380 ti: ffffffc019ff8000 task.ti: ffffffc019ff8000
[ 39.937823] 832 (aplay) PC is at 0xf747baec
[ 39.943600] 832 (aplay) LR is at 0x0
[ 39.948736] 832 (aplay) pc : [<00000000f747baec>] lr : [<0000000000000000>] pstate: 60000010
[ 39.959785] 832 (aplay) sp : ffffffc019ff9ff0
[ 39.965819] x29: 0000000000000000 x28: 0000000000000000
[ 39.973168] x27: 0000000000000000 x26: 0000000000000000
[ 39.980522] x25: 0000000000000000 x24: 0000000000000000
[ 39.987861] x23: 0000000000000000 x22: 0000000000000000
[ 39.995212] x21: 0000000000000000 x20: 0000000000000000
[ 40.002560] x19: 0000000000000000 x18: 0000000000000000
[ 40.009882] x17: 0000000000000000 x16: 0000000000000000
[ 40.017132] x15: 0000000000000000 x14: 00000000f764e7a0
[ 40.024415] x13: 00000000ffc06b88 x12: 000000000001e2cc
[ 40.031706] x11: 00000000ffc06bc4 x10: 000000000001e32c
[ 40.039035] x9 : 000000000001e31c x8 : 0000000000000000
[ 40.046346] x7 : 0000000000000036 x6 : 000000000001e298
[ 40.053629] x5 : 0000000000580830 x4 : 00000000f76feffc
[ 40.060943] x3 : 00000000ffc06ba0 x2 : 00000000ffc06ba0
[ 40.068288] x1 : 00000000400c4150 x0 : 0000000000000000
[ 40.075529] 832 (aplay)
[ 40.079571] 832 (aplay) Bad mode in Synchronous Abort handler detected, code 0x86000007
[ 40.090335] 832 (aplay) CPU: 0 PID: 832 Comm: aplay Not tainted 3.10.0+ #64
[ 40.099783] 832 (aplay) task: ffffffc000861380 ti: ffffffc019ff8000 task.ti: ffffffc019ff8000
[ 40.110928] 832 (aplay) PC is at 0x0
[ 40.116025] 832 (aplay) LR is at 0x0
[ 40.121211] 832 (aplay) pc : [<0000000000000000>] lr : [<0000000000000000>] pstate: 800003c5
[ 40.132337] 832 (aplay) sp : ffffffc019ff9ed0
[ 40.138387] x29: 0000000000000000 x28: 0000000000000000
[ 40.145718] x27: 0000000000000000 x26: 0000000000000000
[ 40.153007] x25: 0000000000000000 x24: 0000000000000000
[ 40.160335] x23: 0000000060000010 x22: 00000000f747baec
[ 40.167745] x21: ffffffc019ff9ff0 x20: 0000000000000000
[ 40.175117] x19: 0000000000000000 x18: 0000000000000000
[ 40.182421] x17: 0000000000000000 x16: 0000000000000000
[ 40.189693] x15: 0000000000000002 x14: 0000000000000082
[ 40.197060] x13: 0000000000000000 x12: 0000000000002090
[ 40.204380] x11: ffffffc000fb73f8 x10: 0000000000000030
[ 40.211699] x9 : ffffffc019ff9c60 x8 : ffffffc000590298
[ 40.219046] x7 : 0000000000000003 x6 : 0000000000000261
[ 40.226390] x5 : 0050000100000000 x4 : 0000000000000000
[ 40.233682] x3 : 0000000000000001 x2 : 0000000000000001
[ 40.241037] x1 : ffffffc019ff9de0 x0 : 0000000000000000
[ 40.248277] 832 (aplay)
[ 40.252134] 832 (aplay) Internal error: Oops - bad mode: 0 [#1] PREEMPT
[ 40.261235] 832 (aplay) CPU: 0 PID: 832 Comm: aplay Not tainted 3.10.0+ #64
[ 40.270649] 832 (aplay) task: ffffffc000861380 ti: ffffffc019ff8000 task.ti: ffffffc019ff8000
[ 40.281834] 832 (aplay) PC is at 0x0
[ 40.286856] 832 (aplay) LR is at 0x0
[ 40.292028] 832 (aplay) pc : [<0000000000000000>] lr : [<0000000000000000>] pstate: 800003c5
[ 40.303084] 832 (aplay) sp : ffffffc019ff9ed0
[ 40.309148] x29: 0000000000000000 x28: 0000000000000000
[ 40.316465] x27: 0000000000000000 x26: 0000000000000000
[ 40.323826] x25: 0000000000000000 x24: 0000000000000000
[ 40.331048] x23: 0000000060000010 x22: 00000000f747baec
[ 40.338425] x21: ffffffc019ff9ff0 x20: 0000000000000000
[ 40.345726] x19: 0000000000000000 x18: 0000000000000000
[ 40.353023] x17: 0000000000000000 x16: 0000000000000000
[ 40.360327] x15: 0000000000000002 x14: 0000000000000082
[ 40.367670] x13: 0000000000000000 x12: 0000000000002090
[ 40.375078] x11: ffffffc000fb73f8 x10: 0000000000000030
[ 40.382440] x9 : ffffffc019ff9c60 x8 : ffffffc000590298
[ 40.389725] x7 : 0000000000000003 x6 : 0000000000000261
[ 40.396999] x5 : 0050000100000000 x4 : 0000000000000000
[ 40.404289] x3 : 0000000000000001 x2 : 0000000000000001
[ 40.411597] x1 : ffffffc019ff9de0 x0 : 0000000000000000
[ 40.418853] 832 (aplay)
[ 40.422720] 832 (aplay) Process aplay (pid: 832, stack limit = 0xffffffc019ff8058)
[ 40.432872] 832 (aplay) Stack: (0xffffffc019ff9ed0 to 0xffffffc019ffa000)
[ 40.442304] 832 (aplay) 9ec0: 00000000 00000000 400c4150 00000000
[ 40.454976] 832 (aplay) 9ee0: ffc06ba0 00000000 ffc06ba0 00000000 f76feffc 00000000 00580830 00000000
[ 40.467667] 832 (aplay) 9f00: 0001e298 00000000 00000036 00000000 00000000 00000000 0001e31c 00000000
[ 40.480310] 832 (aplay) 9f20: 0001e32c 00000000 ffc06bc4 00000000 0001e2cc 00000000 ffc06b88 00000000
[ 40.492832] 832 (aplay) 9f40: f764e7a0 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 40.505377] 832 (aplay) 9f60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 40.517829] 832 (aplay) 9f80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 40.530276] 832 (aplay) 9fa0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 40.542804] 832 (aplay) 9fc0: 00000000 00000000 19ff9ff0 ffffffc0 f747baec 00000000 60000010 00000000
[ 40.555294] 832 (aplay) 9fe0: 00000004 00000000 00000036 00000000 00000000 00000000 00000000 00000000
[ 40.567276] 832 (aplay) Call trace:
[ 40.572258] 832 (aplay) Code: bad PC value
[ 40.578899] 832 (aplay) ---[ end trace 329143aae073dffd ]---
Segmentation fault
[\u@\h: \W]#
BR
nhcao