AirportExpress/64-bit

From Segfault
Jump to: navigation, search

On 64-bit Linux, the following issues were encountered.

64-bit binary

The executable could be built, but crashed when being used:

$ file raop_play/raop_play
raop_play/raop_play: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=4dc54d26fd5646b2c569dc8df737b7dc24857e8b, not stripped
$ gdb raop_play/raop_play 
(gdb) run ae /tmp/a.mp3
Starting program: /usr/local/src/raop-play-git/raop_play/raop_play/raop_play ae /tmp/a.mp3
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
DBG: Server: AirTunes/105.1
DBG: CSeq: 1
DBG: Apple-Response: PKrjBiRlILbamOV+nuY2039CjkZn/ScRX5pWTTseYwlB0ZZpW2jTJsmqqUTNcTnuLHfHsBOhTZP92e2jGcOc78bYv/AHQdLiJPhw34uIgJa9DIyKLE50iiMj12KDdzXbAjR8CUxDFu2s6SOuXnLjw4Est8fHjPiRpAWtRrvl4zhS9xANM+JdwMKHkfOD15iJbVPE3A2EQyuIsiCqOkFEBnnDWT/aX5tOYNeAIYkSH34X+vIngEnvaFu4ELCXLiYYsUD7MhY6n/3Dt0cceyk0I4wkmi0yIz+w2Mh06nh/jmU1PV8QaxvbG+O6/qoDntrZMXjEFZZHk1CAFePHlgIGXQ==
DBG: Transport: RTP/AVP/TCP;unicast;mode=record;server_port=6000
DBG: Session: 1
DBG: Audio-Jack-Status: connected; type=analog
DBG: Server: AirTunes/105.1
DBG: CSeq: 2
DBG: Audio-Latency: 4384
DBG: Server: AirTunes/105.1
DBG: CSeq: 3
DBG: Server: AirTunes/105.1
DBG: CSeq: 4
connected
DBG: audio data type: 3
DBG: id3 tagsize: 0
DBG: sample rate=44100

Program received signal SIGSEGV, Segmentation fault.
__memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:33
33      ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S: No such file or directory.

(gdb) bt full
#0  __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:33
No locals.
#1  0x0000000000403885 in raopcl_send_sample (p=0x6192f0, sample=0x1 <error: Cannot access memory at address 0x1>, count=4255469) at raop_client.c:262
        rval = -1
        len = 61177
        header = "$\000\000\000\360\377\000\000\000\000\000\000\000\000\000"
        header_size = 16
        raopcld = 0x6192f0
        __func__ = "raopcl_send_sample"
#2  0x0000000000402d52 in main (argc=3, argv=0x7fffffffe168) at raop_play.c:267
        host = 0x7fffffffe4d4 "ae"
        fname = 0x7fffffffe4d7 "/tmp/a.mp3"
        port = 5000
        rval = 0
        i = 4
        size = 4255469
        volume = 100
        buf = 0x1 <error: Cannot access memory at address 0x1>
        iact = 0
        act = {__sigaction_handler = {sa_handler = 0x402799 <sig_action>, sa_sigaction = 0x402799 <sig_action>}, sa_mask = {__val = {0 <repeats 16 times>}}, 
          sa_flags = 4, sa_restorer = 0x7c}

32-bit binary

On this Debian/jessie system (amd64), the following packages needed to be installed:

sudo apt-get install libssl-dev:i386 libfltk1.3:i386 libsamplerate-dev:i386 libid3tag0-dev:i386 libid3tag0:i386 libfltk1.3-dev:i386

Add -m32 to CFLAGS:

diff --git a/raop_play/raop_play/Makefile.in b/raop_play/raop_play/Makefile.in
index 4fa69fc..9173204 100644
--- a/raop_play/raop_play/Makefile.in
+++ b/raop_play/raop_play/Makefile.in
@@ -12,7 +12,7 @@ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 TARGET=raop_play
 DESTDIR =
 
-CFLAGS=-Wall
+CFLAGS=-Wall -m32 -g
 OBJS := raop_play.o raop_client.o rtsp_client.o aexcl_lib.o base64.o aes.o m4a_stream.o \
 audio_stream.o wav_stream.o mp3_stream.o flac_stream.o ogg_stream.o aac_stream.o pls_stream.o \
 pcm_stream.o flac_stream.o
@@ -20,7 +20,7 @@ pcm_stream.o flac_stream.o
 all: $(TARGET)
 
 raop_play: $(OBJS)
-       $(CC) -o $@  -lssl -lsamplerate -lid3tag $^
+       $(CC) -m32 -g -o $@ @LIBS@ $^
 
 install:
        $(mkinstalldirs) $(DESTDIR)$(bindir)/

Configure & build with:

CFLAGS="-g -m32" LIBS="-lcrypto" ./configure --prefix=/opt/raop-play
make -C raop_play 

Now we have a 32-bit executable:

$ file raop_play/raop_play

raop_play/raop_play: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=509904c24823023628477b8842316114b18d1ea3, not stripped

$ gdb raop_play/raop_play
 (gdb) run ae /tmp/a.mp3 
Starting program: /usr/local/src/raop-play-git/raop_play/raop_play/raop_play ae /tmp/a.mp3
DBG: Server: AirTunes/105.1
DBG: CSeq: 1
DBG: Apple-Response: O+2pG8bTI6izPMjbyK4qtO9oIQPZZae9nYpPxuYomk0Q4gWlSjW29nd/mUty7XZXjhb9Ynp3erxuXUP5N0oG/CHmHbJ56/rDhP6xYvpYskadZVvAvHqoQQBBpsWEWhPMReH8I/Lt03V9qAbLuYLq3SeGxxhdU8+75OPABkr7jF68N8mOgfR1tNX9YWSZ/xdMJWQBIHwREeYlNCZJ9ghfGS6SF443FnmmVVSxN+ZcXPqTIH9iweXprAQd6DJgO/R3B0YqC4mADJ4/a7KHma3RrXja5Uywabq/PcAmKE3OTAG/HncEKnFTAo/zQdIPf8LiEXc8ga1touLRhQon2Spq4g==
DBG: Transport: RTP/AVP/TCP;unicast;mode=record;server_port=6000
DBG: Session: 1
DBG: Audio-Jack-Status: connected; type=analog
DBG: Server: AirTunes/105.1
DBG: CSeq: 2
DBG: Audio-Latency: 4384
DBG: Server: AirTunes/105.1
DBG: CSeq: 3
DBG: Server: AirTunes/105.1
DBG: CSeq: 4
connected
DBG: audio data type: 3
DBG: id3 tagsize: 0
DBG: sample rate=44100

Program received signal SIGSEGV, Segmentation fault.
0xf7b0ecdc in memcpy () from /lib/i386-linux-gnu/libc.so.6

(gdb) bt full
#0  0xf7b0ecdc in memcpy () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
#1  0x0804abf1 in raopcl_send_sample (p=0x805b058, sample=0x8048f95 <_init+9> "\201", <incomplete sequence \341>, count=-138344480) at raop_client.c:262
        rval = -1
        len = 2028
        header = "$\000\000\000\360\377\000\000\000\000\000\000\000\000\000"
        header_size = 16
        raopcld = 0x805b058
        __func__ = "raopcl_send_sample"
#2  0x0804a256 in main (argc=3, argv=0xffffd2e4) at raop_play.c:267
        host = 0xffffd4d4 "ae"
        fname = 0xffffd4d7 "/tmp/a.mp3"
        port = 5000
        rval = 0
        i = 4
        size = -138344480
        volume = 100
        buf = 0x8048f95 <_init+9> "\201", <incomplete sequence \341>
        iact = 0
        act = {__sigaction_handler = {sa_handler = 0x8049d45 <sig_action>, sa_sigaction = 0x8049d45 <sig_action>}, sa_mask = {__val = {0 <repeats 32 times>}}, 
          sa_flags = 4, sa_restorer = 0xf7c477dd <OPENSSL_cpuid_setup+269>}