[Click] Problem running cross-compiled Click on Android devices

Xinghong Fang xf214 at cam.ac.uk
Wed Jan 25 21:16:11 EST 2012


Hi Eddie,

I haven't find a proper way to use gdb to debug it on the device. Below
is how I reproduce the problem. Assuming the latest NDK has been downloaded
and proper toolchain binary has been added to PATH (so we can use
"arm-linux-androideabi-gcc" directly).

What is the problem?
Cross-compiled Click executable throws segmentation fault when running on
Android devices (as well as emulators).

Where it happens?
Segmentation fault happens every time when the program quits.

Affected Android versions?
As far as I have tested, Android 2.3.3, 3.2 and 4.0 (No problem on 2.1)

Click version used?
Latest version pulled from git (26/Jan/2012)

How to reproduce?
-------------------------------------------------------------
1. Download source from git
$ git clone git://read.cs.ucla.edu/git/click click

2. Configure Click using the following command.
#!/bin/sh
PLT='android-9'
ANDROID='/home/jave/program/android-ndk-r7'
LIBGCC=`arm-linux-androideabi-gcc -print-libgcc-file-name`
./configure --host=arm-linux-androideabi \
CPPFLAGS="-I$ANDROID/platforms/$PLT/arch-arm/usr/include
-I$ANDROID/sources/cxx-stl/gnu-libstdc++/include
-I$ANDROID/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include" \
CXXFLAGS="-fno-rtti -fno-exceptions" \
LDFLAGS="-Wl,-rpath-link=$ANDROID/platforms/$PLT/arch-arm/usr/lib,-dynamic-linker=/system/bin/linker
-L$ANDROID/platforms/$PLT/arch-arm/usr/lib -nostdlib
$ANDROID/platforms/$PLT/arch-arm/usr/lib/crtbegin_dynamic.o" \
LIBS="-lm -lstdc++ -lc $LIBGCC" \
--disable-linuxmodule --disable-dynamic-linking --enable-tools=host

3. Call make to compile. (it seems 'make' called configure again here)
$ make

4. Start a new Android 2.3.3 AVD in the emulator via AVD manager.

5. Upload the compiled Click executable and test config files to the
emulator.
$ adb push userlevel/click /data/click/click
$ adb push conf/test.click /data/click/click
$ adb push conf/test3.click /data/click/click

6. Run Click on the emulator via adb shell
$ adb shell
# cd data/click
# ./click test.click
ok:   40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok:   40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok:   40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok:   40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok:   40 | 45000028 00000000 401177c3 01000001 02000002 13691369
[1] + Stopped (signal)        ./click test.click
#
[1]   Segmentation fault      ./click test.click

7. Try another config file 'test3.click', which should continue forever
unless interrupted manually by ctrl+c.
# ./click test3.click
q1:   69 | 52616e64 6f6d2062 756c6c73 68697420 696e2061 20706163
q1:   69 | 52616e64 6f6d2062 756c6c73 68697420 696e2061 20706163
q2:   69 | 52616e64 6f6d2062 756c6c73 68697420 696e2061 20706163
q1:   69 | 52616e64 6f6d2062 756c6c73 68697420 696e2061 20706163
q1:   69 | 52616e64 6f6d2062 756c6c73 68697420 696e2061 20706163
q2:   69 | 52616e64 6f6d2062 756c6c73 68697420 696e2061 20706163
q1:   69 | 52616e64 6f6d2062 756c6c73 68697420 696e2061 20706163
^C[1] + Stopped (signal)        ./click test3.click
#
[1]   Segmentation fault      ./click test3.click

-------------------------------------------------------

Summary:
>From above we can see Click printed the correct test result, but happened
to throw a segfault on quit. I also tried some other config files and they
all give the same result. In addition, I can reproduced the same result in
Android 3.2 and 4.0 emulator and 2.3.3 on a Galaxy S2. However, there is no
segfault when running on Android 2.1. So I suspect there is something wrong
with the way I cross-compile Click. Could you help me to verify this,
please? Especially step 2 (the configure script). Thank you.

Best,
Xinghong

On Wed, Jan 25, 2012 at 10:16 PM, Eddie Kohler <ekohler at gmail.com> wrote:

> Xinghong,
>
> Can you describe the segmentation fault in more detail? Do you know where
> it happens?
>
> Eddie
>
>
>
> On 1/22/12 7:13 PM, Xinghong Fang wrote:
>
>> Hi everyone,
>>
>> I'm currently undertaking an project which require click to be port to
>> Android. I pulled the latest version of Click from git. Then followed the
>> instruction by Eddie on
>> http://article.gmane.org/**gmane.network.routing.click/**7590<http://article.gmane.org/gmane.network.routing.click/7590>.
>> Then I pushed
>> the compiled "click" executable file to the device using "adb push click
>> /data/click". The problem is, it works fine on Android 2.1. However, on
>> Android 2.3.3 and 4.0, the program throws segmentation fault every time it
>> quits. It seems the program runs perfectly and generates correct result.
>> The segfault only happens when it quits. Does anyone have the same
>> problem?
>> Thank you.
>>
>> Best,
>>
>


-- 
Xinghong Fang

Postgraduate Student
Computer Laboratory
University of Cambridge
Mobile: +447551275316
Email: xf214 at cam.ac.uk


More information about the click mailing list