ChokkaUoM / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

x86 android: no static intermediates #366

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Checkout KitKat with:
repo init -u https://android.googlesource.com/platform/manifest -b 
android-4.4.2_r1
repo sync

2. Apply patch to enable asan for stagefright binary (it lives inside 
frameworks/av/)

diff --git a/cmds/stagefright/Android.mk b/cmds/stagefright/Android.mk
index 561ce02..0721037 100644
--- a/cmds/stagefright/Android.mk
+++ b/cmds/stagefright/Android.mk
@@ -22,6 +22,7 @@ LOCAL_CFLAGS += -Wno-multichar
 LOCAL_MODULE_TAGS := optional

 LOCAL_MODULE:= stagefright
+LOCAL_ADDRESS_SANITIZER:=true

 include $(BUILD_EXECUTABLE)

3. Build for arm:
source build/envsetup.sh
lunch aosp_arm-eng
cd frameworks/av/cmds/stagefright
mm

It will succeed.

4. Now, build for x86:
source build/envsetup.sh
lunch aosp_x86-eng
cd frameworks/av/cmds/stagefright
mm

This will fail with the following error:
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4.2
TARGET_PRODUCT=aosp_x86
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86
TARGET_ARCH_VARIANT=x86
TARGET_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-43-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=KOT49H
OUT_DIR=out
============================================
make: Entering directory `/usr/local/google/home/krasin/klp-mr1-release'
make: *** No rule to make target 
`out/target/product/generic_x86/obj/STATIC_LIBRARIES/libasan_intermediates/expor
t_includes', needed by `out
/target/product/generic_x86/obj/EXECUTABLES/stagefright_intermediates/import_inc
ludes'.  Stop.

Original issue reported on code.google.com by krasin@google.com on 20 Dec 2014 at 9:03

GoogleCodeExporter commented 9 years ago
Per off-the-band advice, I have enabled asan for non-arm Android with the 
following patch to external/compiler-rt:

diff --git a/lib/asan/Android.mk b/lib/asan/Android.mk
index 62fdd17..d44dfc8 100644
--- a/lib/asan/Android.mk
+++ b/lib/asan/Android.mk
@@ -17,7 +17,7 @@

 LOCAL_PATH:= $(call my-dir)

-ifeq ($(TARGET_ARCH),arm)
+#ifeq ($(TARGET_ARCH),arm)

 ASAN_NEEDS_SEGV=0
 ASAN_HAS_EXCEPTIONS=1
@@ -195,4 +195,4 @@ LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk

 include $(BUILD_EXECUTABLE)

-endif # ifeq($(TARGET_ARCH),arm)
+#endif # ifeq($(TARGET_ARCH),arm)
diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 
b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
index 2f9b685..6973bbb 100644
--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -198,11 +198,11 @@ uptr GetTlsSize() {
 // sizeof(struct thread) from glibc.
 // There has been a report of this being different on glibc 2.11. We don't know
 // when this change happened, so 2.12 is a conservative estimate.
-#if __GLIBC_PREREQ(2, 12)
+//#if __GLIBC_PREREQ(2, 12)
 const uptr kThreadDescriptorSize = FIRST_32_SECOND_64(1216, 2304);
-#else
-const uptr kThreadDescriptorSize = FIRST_32_SECOND_64(1168, 2304);
-#endif
+  //#else
+  //const uptr kThreadDescriptorSize = FIRST_32_SECOND_64(1168, 2304);
+  //#endif

 uptr ThreadDescriptorSize() {
   return kThreadDescriptorSize;

Unfortunately, it didn't help. I still get the same issue:

make: *** No rule to make target 
`out/target/product/generic_x86/obj/STATIC_LIBRARIES/libasan_intermediates/expor
t_includes', needed by 
`out/target/product/generic_x86/obj/EXECUTABLES/stagefright_intermediates/import
_includes'.  Stop.

Original comment by krasin@google.com on 22 Dec 2014 at 8:07

GoogleCodeExporter commented 9 years ago
Oh, that was unexpected.

I have manually build libasan and friends with:

$ cd external/compiler-rt
$ mm
$ cd ../..

Then:

$ cd frameworks/av/cmds/stagefright
$ mm

And it succeeded (see below). It looks like a missing dependency somewhere.

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4.2
TARGET_PRODUCT=aosp_x86
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86
TARGET_ARCH_VARIANT=x86
TARGET_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-43-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=KOT49H
OUT_DIR=out
============================================
make: Entering directory `/usr/local/google/home/krasin/klp-mr1-release'
Import includes file: 
out/target/product/generic_x86/obj/EXECUTABLES/stagefright_intermediates/import_
includes
target Executable: stagefright 
(out/target/product/generic_x86/obj/EXECUTABLES/stagefright_intermediates/LINKED
/stagefright)
target Symbolic: stagefright 
(out/target/product/generic_x86/symbols/system/bin/stagefright)
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/stagefright_intermediates/export_
includes
target Strip: stagefright 
(out/target/product/generic_x86/obj/EXECUTABLES/stagefright_intermediates/stagef
right)
Install: out/target/product/generic_x86/system/bin/stagefright
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/record_intermediates/export_inclu
des
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/recordvideo_intermediates/export_
includes
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/audioloop_intermediates/export_in
cludes
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/stream_intermediates/export_inclu
des
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/sf2_intermediates/export_includes
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/codec_intermediates/export_includ
es
Export includes file: frameworks/av/cmds/stagefright/Android.mk -- 
out/target/product/generic_x86/obj/EXECUTABLES/muxer_intermediates/export_includ
es
make: Leaving directory `/usr/local/google/home/krasin/klp-mr1-release'

Original comment by krasin@google.com on 22 Dec 2014 at 8:13

GoogleCodeExporter commented 9 years ago
Not sure what's wrong with the dependencies. Did you build with top-level make?

As for the sanitizer_common fix, this code has changed significantly in the 
upstream. 

Original comment by euge...@google.com on 23 Dec 2014 at 9:31

GoogleCodeExporter commented 9 years ago
At this point, I am sure that the issue was my misunderstanding of how mm 
works. Please, close this bug as invalid.

Original comment by krasin@google.com on 24 Dec 2014 at 12:23

GoogleCodeExporter commented 9 years ago

Original comment by konstant...@gmail.com on 24 Dec 2014 at 12:33

GoogleCodeExporter commented 9 years ago
There is "mma" that's like mm but respects cross-project dependencies.

Original comment by euge...@google.com on 24 Dec 2014 at 9:45

GoogleCodeExporter commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Original comment by ramosian.glider@gmail.com on 30 Jul 2015 at 9:14