Re: [alsa-devel] Errors in application building
On 7/3/07, Lee Revell rlrevell@joe-job.com wrote:
Use gdb, strace is not useful for this
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
Hello all:
Just tried to run with the warnings:
grhuser@pcL7:$ arm-linux-gcc -lasound -Wall -o grh_audio grh_audio.c grh_audio.c: In function 'grh_capture': grh_audio.c:112: warning: pointer targets in passing argument 3 of
'snd_pcm_hw_params_set_rate_near' differ in signedness
grh_audio.c: In function 'grh_playback': grh_audio.c:207: warning: pointer targets in passing argument 3 of
'snd_pcm_hw_params_set_rate_near' differ in signedness
Which comes from the code:
112: if ((err = snd_pcm_hw_params_set_rate_near (capture_handle,
hw_params, &sample_rate, 0)) < 0)
207: if ((err = snd_pcm_hw_params_set_rate_near (playback_handle,
hw_params, &sample_rate, 0)) < 0)
However, I get a seg fault when I ran it. The strace of this is:
/usr/sbin $ strace grh_audio execve("/usr/sbin/grh_audio", ["grh_audio"], [/* 7 vars */]) = 0 mmap2(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
=
0x40005000 stat("/etc/ld.so.cache", {st_mode=S_IFREG|0644, st_size=1150, ...}) = 0 open("/etc/ld.so.cache", O_RDONLY) = 3 mmap2(NULL, 1150, PROT_READ, MAP_SHARED, 3, 0) = 0x40006000 close(3) = 0 open("/usr/lib/libasound.so.2", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0755, st_size=762072, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0x\367\1\000"..., 4096) = 4096 mmap2(NULL, 794624, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000e000 mmap2(0x4000e000, 745564, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
= 0x4000e000 mmap2(0x400cc000, 15508, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xb6) = 0x400cc000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0X\25\0\000"..., 4096) = 4096 mmap2(NULL, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x400d0000
mmap2(0x400d0000, 28800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
- =
0x400d0000 mmap2(0x400df000, 548, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x7)
= 0x400df000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\253\0"..., 4096) = 4096 mmap2(NULL, 360448, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400e0000 mmap2(0x400e0000, 302380, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
= 0x400e0000 mmap2(0x40132000, 5172, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x4a) = 0x40132000 mmap2(0x40134000, 16020, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40130 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libm.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=45812, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0t\22\0\000"..., 4096) = 4096 mmap2(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40138000
mmap2(0x40138000, 41428, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
- =
0x40138000 mmap2(0x4014a000, 4100, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0xa)
= 0x4014a000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libdl.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=8900, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\10\0\000"..., 4096) = 4096 mmap2(NULL, 40960, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4014c000
mmap2(0x4014c000, 5760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
- =
0x4014c000 mmap2(0x40155000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x1)
= 0x40155000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libpthread.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=63852, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0D<\0\0004"..., 4096) = 4096 mmap2(NULL, 106496, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40156000 mmap2(0x40156000, 40952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
- =
0x40156000 mmap2(0x40168000, 21732, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xa) = 0x40168000 mmap2(0x4016e000, 5788, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4016e0 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 munmap(0x40006000, 1150) = 0 stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=21096, ...})
= 0
mprotect(0x40132000, 4096, PROT_READ) = 0 mprotect(0x4014a000, 4096, PROT_READ) = 0 mprotect(0x40155000, 4096, PROT_READ) = 0 mprotect(0x40168000, 4096, PROT_READ) = 0 mprotect(0x4000c000, 4096, PROT_READ) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo ...}) = 0 getpid() = 756 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) =
0
setrlimit(RLIMIT_STACK, {rlim_cur=2040*1024, rlim_max=RLIM_INFINITY}) =
0
rt_sigaction(SIGRTMIN, {0x4015fd70, [], 0x4000000 /* SA_??? */}, NULL,
- =
0 rt_sigaction(SIGRT_1, {0x4015fc98, [RTMIN], 0x4000000 /* SA_??? */},
NULL,
- = 0
rt_sigaction(SIGRT_2, {0x4015f2d0, [], 0x4000000 /* SA_??? */}, NULL, 8)
= 0
rt_sigprocmask(SIG_BLOCK, [RTMIN], NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RT_1], NULL, 8) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ Process 756 detached
I am still trying to locate why those warnings are popping up, but as
that
part of the code is not called immediately, I am wondering why the seg
fault
is occurring. Any clues?
Lee:
Have attempted to run this with gdb. However, I get:
/usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.5 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"...(no debugging symbols found)
(gdb)
Trying to determine why...will let you know asap what I find.
Paul
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
On 7/3/07, Lee Revell rlrevell@joe-job.com wrote:
Use gdb, strace is not useful for this
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
Hello all:
Just tried to run with the warnings:
grhuser@pcL7:$ arm-linux-gcc -lasound -Wall -o grh_audio grh_audio.c grh_audio.c: In function 'grh_capture': grh_audio.c:112: warning: pointer targets in passing argument 3 of
'snd_pcm_hw_params_set_rate_near' differ in signedness
grh_audio.c: In function 'grh_playback': grh_audio.c:207: warning: pointer targets in passing argument 3 of
'snd_pcm_hw_params_set_rate_near' differ in signedness
Which comes from the code:
112: if ((err = snd_pcm_hw_params_set_rate_near (capture_handle,
hw_params, &sample_rate, 0)) < 0)
207: if ((err = snd_pcm_hw_params_set_rate_near (playback_handle,
hw_params, &sample_rate, 0)) < 0)
However, I get a seg fault when I ran it. The strace of this is:
/usr/sbin $ strace grh_audio execve("/usr/sbin/grh_audio", ["grh_audio"], [/* 7 vars */]) = 0 mmap2(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40005000 stat("/etc/ld.so.cache", {st_mode=S_IFREG|0644, st_size=1150, ...}) =
0
open("/etc/ld.so.cache", O_RDONLY) = 3 mmap2(NULL, 1150, PROT_READ, MAP_SHARED, 3, 0) = 0x40006000 close(3) = 0 open("/usr/lib/libasound.so.2", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0755, st_size=762072, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0x\367\1\000"..., 4096) = 4096 mmap2(NULL, 794624, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000e000 mmap2(0x4000e000, 745564, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0)
= 0x4000e000 mmap2(0x400cc000, 15508, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3,
0xb6) = 0x400cc000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0X\25\0\000"..., 4096) = 4096 mmap2(NULL, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x400d0000
mmap2(0x400d0000, 28800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) =
0x400d0000 mmap2(0x400df000, 548, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x7)
= 0x400df000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\253\0"..., 4096) = 4096 mmap2(NULL, 360448, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400e0000 mmap2(0x400e0000, 302380, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0)
= 0x400e0000 mmap2(0x40132000, 5172, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3,
0x4a) = 0x40132000 mmap2(0x40134000, 16020, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40130 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libm.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=45812, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0t\22\0\000"..., 4096) = 4096 mmap2(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40138000
mmap2(0x40138000, 41428, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) =
0x40138000 mmap2(0x4014a000, 4100, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0xa)
= 0x4014a000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libdl.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=8900, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\10\0\000"..., 4096) = 4096 mmap2(NULL, 40960, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4014c000
mmap2(0x4014c000, 5760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
- =
0x4014c000 mmap2(0x40155000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0x1)
= 0x40155000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libpthread.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=63852, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0D<\0\0004"..., 4096) = 4096 mmap2(NULL, 106496, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40156000 mmap2(0x40156000, 40952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) =
0x40156000 mmap2(0x40168000, 21732, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3,
0xa) = 0x40168000 mmap2(0x4016e000, 5788, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4016e0 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 munmap(0x40006000, 1150) = 0 stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=21096,
...}) = 0
mprotect(0x40132000, 4096, PROT_READ) = 0 mprotect(0x4014a000, 4096, PROT_READ) = 0 mprotect(0x40155000, 4096, PROT_READ) = 0 mprotect(0x40168000, 4096, PROT_READ) = 0 mprotect(0x4000c000, 4096, PROT_READ) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon
echo
...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon
echo
...}) = 0 getpid() = 756 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY})
= 0
setrlimit(RLIMIT_STACK, {rlim_cur=2040*1024, rlim_max=RLIM_INFINITY})
= 0
rt_sigaction(SIGRTMIN, {0x4015fd70, [], 0x4000000 /* SA_??? */}, NULL,
- =
0 rt_sigaction(SIGRT_1, {0x4015fc98, [RTMIN], 0x4000000 /* SA_??? */},
NULL,
- = 0
rt_sigaction(SIGRT_2, {0x4015f2d0, [], 0x4000000 /* SA_??? */}, NULL,
- = 0
rt_sigprocmask(SIG_BLOCK, [RTMIN], NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RT_1], NULL, 8) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ Process 756 detached
I am still trying to locate why those warnings are popping up, but as
that
part of the code is not called immediately, I am wondering why the seg
fault
is occurring. Any clues?
Lee:
Have attempted to run this with gdb. However, I get:
/usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.5 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"...(no debugging symbols found)
(gdb)
Trying to determine why...will let you know asap what I find.
Still trying to see if I can determine what is going on here. I tried 'run' with gdb and get the following:
/usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.5 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"... (gdb) run Starting program: /usr/sbin/grh_audio Using host libthread_db library "libthread_db.so.1". Segmentation fault
Any ideas why this is occurring.
Also, I get the following warning when compiling:
grh_audio.c:112: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness
for the line:
112: if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &sample_rate, 0)) < 0)
I have googled this and cannot seem to find an answer. I used some example code for this, so perhaps there is something wrong with that. I tried to find a page detailing the call, but could not even find that.
Any clues, pointers, etc. on this are greatly appreciated.
Paul
On 7/5/07, Paul Kavan pkavan@gmail.com wrote:
On 7/3/07, Paul Kavan <pkavan@gmail.com > wrote:
On 7/3/07, Lee Revell rlrevell@joe-job.com wrote:
Use gdb, strace is not useful for this
On 7/3/07, Paul Kavan pkavan@gmail.com wrote:
Hello all:
Just tried to run with the warnings:
grhuser@pcL7:$ arm-linux-gcc -lasound -Wall -o grh_audio
grh_audio.c
grh_audio.c: In function 'grh_capture': grh_audio.c:112: warning: pointer targets in passing argument 3 of
'snd_pcm_hw_params_set_rate_near' differ in signedness
grh_audio.c: In function 'grh_playback': grh_audio.c:207: warning: pointer targets in passing argument 3 of
'snd_pcm_hw_params_set_rate_near' differ in signedness
Which comes from the code:
112: if ((err = snd_pcm_hw_params_set_rate_near (capture_handle,
hw_params, &sample_rate, 0)) < 0)
207: if ((err = snd_pcm_hw_params_set_rate_near
(playback_handle,
hw_params, &sample_rate, 0)) < 0)
However, I get a seg fault when I ran it. The strace of this is:
/usr/sbin $ strace grh_audio execve("/usr/sbin/grh_audio", ["grh_audio"], [/* 7 vars */]) = 0 mmap2(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
- =
0x40005000 stat("/etc/ld.so.cache", {st_mode=S_IFREG|0644, st_size=1150, ...})
= 0
open("/etc/ld.so.cache", O_RDONLY) = 3 mmap2(NULL, 1150, PROT_READ, MAP_SHARED, 3, 0) = 0x40006000 close(3) = 0 open("/usr/lib/libasound.so.2", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0755, st_size=762072, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0x\367\1\000"..., 4096) = 4096 mmap2(NULL, 794624, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000e000 mmap2(0x4000e000, 745564, PROT_READ|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED, 3, 0)
= 0x4000e000 mmap2(0x400cc000, 15508, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3,
0xb6) = 0x400cc000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0X\25\0\000"..., 4096) = 4096 mmap2(NULL, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x400d0000
mmap2(0x400d0000, 28800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) =
0x400d0000 mmap2(0x400df000, 548, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0x7)
= 0x400df000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\253\0"..., 4096) = 4096 mmap2(NULL, 360448, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400e0000 mmap2(0x400e0000, 302380, PROT_READ|PROT_EXEC,
MAP_PRIVATE|MAP_FIXED, 3, 0)
= 0x400e0000 mmap2(0x40132000, 5172, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3,
0x4a) = 0x40132000 mmap2(0x40134000, 16020, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40130 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libm.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=45812, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0t\22\0\000"..., 4096) = 4096 mmap2(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40138000
mmap2(0x40138000, 41428, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) =
0x40138000 mmap2(0x4014a000, 4100, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0xa)
= 0x4014a000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libdl.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=8900, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\10\0\000"..., 4096) = 4096 mmap2(NULL, 40960, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4014c000
mmap2(0x4014c000, 5760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) =
0x4014c000 mmap2(0x40155000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0x1)
= 0x40155000 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libpthread.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=63852, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) =
0x40007000 read(3, "\177ELF\1\1\1a\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0D<\0\0004"..., 4096) = 4096 mmap2(NULL, 106496, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40156000 mmap2(0x40156000, 40952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) =
0x40156000 mmap2(0x40168000, 21732, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3,
0xa) = 0x40168000 mmap2(0x4016e000, 5788, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4016e0 close(3) = 0 munmap(0x40007000, 4096) = 0 open("/lib/libgcc_s.so.1", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=44167, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 open("/lib/libc.so.0", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=309840, ...}) = 0 close(3) = 0 munmap(0x40006000, 1150) = 0 stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=21096,
...}) = 0
mprotect(0x40132000, 4096, PROT_READ) = 0 mprotect(0x4014a000, 4096, PROT_READ) = 0 mprotect(0x40155000, 4096, PROT_READ) = 0 mprotect(0x40168000, 4096, PROT_READ) = 0 mprotect(0x4000c000, 4096, PROT_READ) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon
echo
...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon
echo
...}) = 0 getpid() = 756 getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024,
rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_STACK, {rlim_cur=2040*1024,
rlim_max=RLIM_INFINITY}) = 0
rt_sigaction(SIGRTMIN, {0x4015fd70, [], 0x4000000 /* SA_??? */},
NULL, 8) =
0 rt_sigaction(SIGRT_1, {0x4015fc98, [RTMIN], 0x4000000 /* SA_??? */},
NULL,
- = 0
rt_sigaction(SIGRT_2, {0x4015f2d0, [], 0x4000000 /* SA_??? */},
NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [RTMIN], NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RT_1], NULL, 8) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ Process 756 detached
I am still trying to locate why those warnings are popping up, but
as that
part of the code is not called immediately, I am wondering why the
seg fault
is occurring. Any clues?
Lee:
Have attempted to run this with gdb. However, I get:
/usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.5 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"...(no debugging symbols found)
(gdb)
Trying to determine why...will let you know asap what I find.
Still trying to see if I can determine what is going on here. I tried 'run' with gdb and get the following:
/usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.5 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"... (gdb) run Starting program: /usr/sbin/grh_audio Using host libthread_db library "libthread_db.so.1". Segmentation fault
Any ideas why this is occurring.
Also, I get the following warning when compiling:
grh_audio.c:112: warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness
for the line:
112: if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &sample_rate, 0)) < 0)
I have googled this and cannot seem to find an answer. I used some example code for this, so perhaps there is something wrong with that. I tried to find a page detailing the call, but could not even find that.
Any clues, pointers, etc. on this are greatly appreciated.
Paul
Hello all:
I have worked on getting some things cleaned up in my kernel and rfs to ensure I was not running out of ramdisk space on my arm development board. I am confident that part is okay now, but still getting a segmentation fault when I try to run my application. Using gdb, I still get:
--snip-- /usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.5 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"... (gdb) start Breakpoint 1 at 0x8a4c: file grh_audio.c, line 32. Starting program: /usr/sbin/grh_audio Using host libthread_db library "libthread_db.so.1". Segmentation fault --snip--
Not sure what the problem is. I have the alsa libs configured as they are supposed to. I assume that the problem has to do with the alsa-libs, but I have been successful in getting aplay to work.
Any suggestions?
Paul
*************************************** Paul David Kavan Project Engineer GRH Electronics, Inc. 402-734-4900 pkavan@gmail.com ***************************************
On Tue, 10 Jul 2007 14:19:32 -0500 "Paul Kavan" pkavan@gmail.com wrote:
Hello all:
I have worked on getting some things cleaned up in my kernel and rfs to ensure I was not running out of ramdisk space on my arm development board. I am confident that part is okay now, but still getting a segmentation fault when I try to run my application. Using gdb, I still get:
--snip-- /usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
--snip--
Not sure what the problem is. I have the alsa libs configured as they are supposed to. I assume that the problem has to do with the alsa-libs, but I have been successful in getting aplay to work.
Any suggestions?
Actually, I would guess that the problem is more likely related to GDB, and more specifically that it can't find "libthread_db.so.1" in /usr/lib.
On 7/10/07, J. Scott Merritt AlsaUser@pragmasoft.com wrote:
On Tue, 10 Jul 2007 14:19:32 -0500 "Paul Kavan" pkavan@gmail.com wrote:
Hello all:
I have worked on getting some things cleaned up in my kernel and rfs to ensure I was not running out of ramdisk space on my arm development
board. I
am confident that part is okay now, but still getting a segmentation
fault
when I try to run my application. Using gdb, I still get:
--snip-- /usr/sbin $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
--snip--
Not sure what the problem is. I have the alsa libs configured as they
are
supposed to. I assume that the problem has to do with the alsa-libs, but
I
have been successful in getting aplay to work.
Any suggestions?
Actually, I would guess that the problem is more likely related to GDB, and more specifically that it can't find "libthread_db.so.1" in /usr/lib.
I am working on the libthread_db issue right now. Is proving to be harder than I would have expected. Anyway, I did determine the problem causing the warnings:
warning: pointer targets in passing argument 3 of 'snd_pcm_hw_params_set_rate_near' differ in signedness
was due to sample_rate being defined as an int and not an unsigned int. Changing that cleared that warning.
I will let you know what happens once I get the libthread_db going.
Paul
Okay, I have the libthread_db issue somewhat resolved. The error in dlopen still pops up, but it is working. I trimmed my code down to see if I could determine the problem and I think I know where it is at, but not why or how to resolve it.
My code looks like this:
/*************************************************************************/ #include <stdio.h> #include <alsa/asoundlib.h>
/************************************* * Variable and Function Declarations *************************************/ int audio_type; //0 = sleep; 1 = capture; 2 = playback int nchannels = 1; int buffer_size = 512; unsigned int sample_rate = 8000; int bits = 8; char *snd_device_in = "hw:0,0"; char *snd_device_out = "hw:0,0";
/************************************* * Main Program Section *************************************/ int main(void) { //Testing routine printf("Press enter to begin recording\n"); getchar(); //grh_capture(); printf("Audio Captured. Press enter to playback\n"); getchar();
return 0; } /*************************************************************************/
When I attempt to run I get a segmentation fault. With GDB, I am getting:
/*************************************************************************/ /usr/sbin $ gdb grh_audio0
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.4 Copyright 2005 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"... (gdb) start Breakpoint 1 at 0x8604: file grh_audio0.c, line 27. Starting program: /usr/sbin/grh_audio0
Program received signal SIGSEGV, Segmentation fault. 0x40124ab8 in _pthread_cleanup_push_defer () from /lib/libc.so.0 (gdb) continue Continuing.
Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. (gdb) /*************************************************************************/
Do the alsa libraries link to pthread? If so, I should probably be compiling with -lpthread. Does anyone else see something I am missing that could be causing the segfault?
Thanks.
Paul
*************************************** Paul David Kavan Project Engineer GRH Electronics, Inc. 402-734-4900 pkavan@gmail.com ***************************************
Do the alsa libraries link to pthread? If so, I should probably be compiling with -lpthread. Does anyone else see something I am missing that could be causing the segfault?
compiling with -lpthread appears to have solved the segfault issue. I do not get that error when I do not include the alsa lib, so I assume something in there is linking to pthread--I am not familiar enough yet with alsa to know for sure.
Now I will continue building in the audio funtionality to see if I can get it rolling.
Paul
Hello All:
Okay, I have progressed past the segfault issue. Definitely was the lack of -lpthread in the compile. Now I have the code in place to do a simple read/write operation to ensure I can make the application capture and play audio. I copied some example code and am trying to get it to work. I can scope my pcm interface and it appears to be working, but no audio as of yet. I am not sure how ALSA is dealing with the audio buffer, so it may be a fundamental problem with that. It may also be the way I am setting the parameters. Both arecord and aplay work just fine, so I do not believe it is a hardware or driver issue.
For clarity, I am using ALSA 1.0.14a with an ARM9 processor using the SoC driver package and a custom machine/codec driver for an at91sam9260ek dev board and winbond w6811 codec. It is a simple pcm, mono, 8k codec. My params are:
Access Type: SND_PCM_ACCESS_RW_INTERLEAVED Sample Format: SND_PCM_FORMAT_S8 Sample Rate: 8000 Channel Count: 1
My code is attached. Through gdb I get the following:
--snip-- ~ $ gdb grh_audio
dlopen failed on 'libthread_db.so.1' - File not found GDB will not be able to debug pthreads.
GNU gdb 6.4 Copyright 2005 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "arm-linux-uclibc"... (gdb) break 131 Breakpoint 1 at 0x8f50: file grh_audio0.c, line 131. (gdb) break 214 Breakpoint 2 at 0x9364: file grh_audio0.c, line 214. (gdb) display buf (gdb) start Breakpoint 3 at 0x8a8c: file grh_audio0.c, line 33. Starting program: /usr/sbin/grh_audio main () at grh_audio0.c:33 33 grh_audio0.c: No such file or directory. in grh_audio0.c 1: buf = {0 <repeats 512 times>} (gdb) continue Continuing. Press enter to begin recording
Breakpoint 1, grh_capture () at grh_audio0.c:131 131 in grh_audio0.c 1: buf = {-776, -772, -1796, -2056, -1800, -263, -1, -1, -1, -1, -1793, -4, -4, -772, -4, -769, -1, -1, -1, -1, -1, -769, -772, -772, -776, -770, -4, -770, -1, -1, -1, -1, -1, -1, -1794, -1801, -1801, -1544, -1, -1, -769, -257, -1, -1, -1, -4, -1800, -1800, -776, -1, -2, -4, -257, -2, -1, -1, -1, -1, -769, -260, -257, -769, -4, -1, -1, -1, -1, -769, -1, -4, -769, -2, -1800, -2057, -1800, -4, -770, -772, -772, -2, -1, -1, -769, -775, -1799, -260, -2, -1, -1, -1, -1, -257, -769, -1796, -264, -1, -1, -264, -769, -769, -1, -1, -1, -1, -1, -772, -4, -1801, -3080, -1800, -772, -1, -258, -769, -4, -776, -769, -1, -1, -770, -772, -1, -1, -1, -769, -1, -1, -1, -1, -1, -1, -260, -2, -1, -1, -258, -2, -260, -1537, -1800, -1544, -772, -769,
-1, -769, -1540, -769, -2, -1, -1, -769, -260, -260, -1540, -260, -257, -2, -769, -1, -1, -1, -770, -2056, -8, -257, -2, -7, -1, -1, -1, -1, -1, -2, -1, -1, -1793, -1796, -1801, -772, -8, -1, -1537, -1799, -775, -1, -1, -1,
-4, -260, -769, -2, -1, -257, -769, -1, -1, -1, -769, -1793, -775...} (gdb) continue Continuing. Audio Captured. Press enter to playback
Breakpoint 2, grh_playback () at grh_audio0.c:214 214 in grh_audio0.c 1: buf = {-776, -772, -1796, -2056, -1800, -263, -1, -1, -1, -1, -1793, -4, -4, -772, -4, -769, -1, -1, -1, -1, -1, -769, -772, -772, -776, -770, -4, -770, -1, -1, -1, -1, -1, -1, -1794, -1801, -1801, -1544, -1, -1, -769, -257, -1, -1, -1, -4, -1800, -1800, -776, -1, -2, -4, -257, -2, -1, -1, -1, -1, -769, -260, -257, -769, -4, -1, -1, -1, -1, -769, -1, -4, -769, -2, -1800, -2057, -1800, -4, -770, -772, -772, -2, -1, -1, -769, -775, -1799, -260, -2, -1, -1, -1, -1, -257, -769, -1796, -264, -1, -1, -264, -769, -769, -1, -1, -1, -1, -1, -772, -4, -1801, -3080, -1800, -772, -1, -258, -769, -4, -776, -769, -1, -1, -770, -772, -1, -1, -1, -769, -1, -1, -1, -1, -1, -1, -260, -2, -1, -1, -258, -2, -260, -1537, -1800, -1544, -772, -769,
-1, -769, -1540, -769, -2, -1, -1, -769, -260, -260, -1540, -260, -257, -2, -769, -1, -1, -1, -770, -2056, -8, -257, -2, -7, -1, -1, -1, -1, -1, -2, -1, -1, -1793, -1796, -1801, -772, -8, -1, -1537, -1799, -775, -1, -1, -1,
-4, -260, -769, -2, -1, -257, -769, -1, -1, -1, -769, -1793, -775...} (gdb) quit The program is running. Exit anyway? (y or n) y ~ $ --snip--
participants (2)
-
J. Scott Merritt
-
Paul Kavan