libpulsecommon.so unaligned memory access issue
Submitted by Yupeng Chang
Assigned to pul..@..op.org
Description
I cross compiled PulseAudio 4.0 using codesourcery 2011.09 to ARM platform with the following CFLAGS -march=armv6k -mtune=arm1136j-s -msoft-float -O3 -fPIC
pulseaudio daemon runs perfectly without any problem, but when I start to run client application like pactl info, the connection always fail with the following error messages:
pactl info
I: [pulseaudio][pulsecore/client.c:80 pa_client_new()] Created 0 "Native client (UNIX socket client)" D: [pulseaudio][pulsecore/protocol-dbus.c:773 pa_dbus_protocol_add_interface()] Interface org.PulseAudio.Core1.Client added for object /org/pulseaudio/core1/client0 D: [pulseaudio][pulsecore/protocol-native.c:2599 command_auth()] Protocol version: remote 28, local 28 I: [pulseaudio][pulsecore/protocol-native.c:2632 command_auth()] Got credentials: uid=0 gid=0 success=1 D: [pulseaudio][pulsecore/protocol-native.c:2662 command_auth()] SHM possible: yes D: [pulseaudio][pulsecore/protocol-native.c:2680 command_auth()] Negotiated SHM: yes E: [pulseaudio][pulsecore/protocol-native.c:1939 protocol_error()] protocol error, kicking client I: [pulseaudio][pulsecore/client.c:102 pa_client_free()] Freed 0 "Native client (UNIX socket client)" D: [pulseaudio][pulsecore/protocol-dbus.c:835 pa_dbus_protocol_remove_interface()] Interface org.PulseAudio.Core1.Client removed from object /org/pulseaudio/core1/client0 Connection failure: Connection terminated
I did some digging on this error, I found connection is terminated on function: command_set_client_name(), and the root failure is in function: pa_tagstruct_get_arbitrary(), on this check "if (t->data[t->rindex] != PA_TAG_ARBITRARY)".
Then I print out t->data[t->rindex] value to see if it's PA_TAG_ARBITRARY, what is strange is that this value is a randome value.
I go back to check the compiling log, and found the following warnings: pulsecore/hashmap.c: In function 'remove_entry': pulsecore/hashmap.c:94:9: warning: cast increases required alignment of target type [-Wcast-align] pulsecore/hashmap.c: In function 'hash_scan': pulsecore/hashmap.c:116:14: warning: cast increases required alignment of target type [-Wcast-align] pulsecore/hashmap.c: In function 'pa_hashmap_put': pulsecore/hashmap.c:141:22: warning: cast increases required alignment of target type [-Wcast-align] pulsecore/hashmap.c:143:9: warning: cast increases required alignment of target type [-Wcast-align] pulsecore/hashmap.c:144:9: warning: cast increases required alignment of target type [-Wcast-align] pulsecore/hashmap.c:145:5: warning: cast increases required alignment of target type [-Wcast-align]
These files are included in libpulsecommon.so
Then I have to add -mno-unaligned-access to CLFAGS, then re-compile pulseaudio again. I replaced the original one with newly compiled libpulsecommon.so, leaving other libraries untouched, everything goes well without any issue.
So I think this must be an unaligned memory access issue in libpulsecommon.so
Please help to fix this!!