uber / nanoscope-art

Apache License 2.0
49 stars 13 forks source link

ART stack frame size recommendation #24

Closed jackluo923 closed 5 years ago

jackluo923 commented 5 years ago

Problem: During compilation, the compiler gave a warning stating the stack frame size of 4220 bytes in art::NanoscopeSampler::signal_handler and aborted compilation (exact error message is at the bottom). I believe the source of the problem originates from allocating a 4K char buffer in runtime/nanoscope_sample.cc:136. The maximum stack size isn't clear from the documentation, but is designed to generate warning if its larger than 2700, 6000 or 1728 bytes according to build/Android.common_build.mk:346-350 depending on different mode.

Questions:

Full compilation error message:


[  0% 2/20201] target  C++: libart_32 <= art/runtime/nanoscope_sampler.cc
FAILED: /bin/bash -c "(PWD=/proc/self/cwd  prebuilts/clang/host/linux-x86/clang-2690385/bin/clang++ -I external/gtest/include -I external/icu/icu4c/source/common -I external/lz4/lib -I external/valgrind/include -I external/valgrind -I external/vixl/src -I external/zlib -I bionic/libc/private -I art/cmdline -I art/sigchainlib -I art -I art/runtime -I out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates -I out/target/product/generic_x86_64/gen/SHARED_LIBRARIES/libart_intermediates -I libnativehelper/include/nativehelper \$(cat out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/import_includes) -isystem system/core/include -isystem system/media/audio/include -isystem hardware/libhardware/include -isystem hardware/libhardware_legacy/include -isystem hardware/ril/include -isystem libnativehelper/include -isystem frameworks/native/include -isystem frameworks/native/opengl/include -isystem frameworks/av/include -isystem frameworks/base/include -isystem out/target/product/generic_x86_64/obj/include -isystem bionic/libc/arch-x86/include -isystem bionic/libc/include -isystem bionic/libc/kernel/uapi -isystem bionic/libc/kernel/common -isystem bionic/libc/kernel/uapi/asm-x86 -isystem bionic/libm/include -isystem bionic/libm/include/i387 -c    -fno-exceptions -Wno-multichar -O2 -Wa,--noexecstack -Werror=format-security -D_FORTIFY_SOURCE=2 -Wstrict-aliasing=2 -ffunction-sections -fno-short-enums -fstrict-aliasing -funwind-tables -fstack-protector-strong -m32 -no-canonical-prefixes -march=prescott -msse4 -msse4.1 -msse4.2 -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time -O2 -g -fno-strict-aliasing -DNDEBUG -UDEBUG  -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -nostdlibinc    -msse3 -target i686-linux-android -Bprebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9/x86_64-linux-android/bin -mstackrealign    -Wsign-promo  -Wno-inconsistent-missing-override -nostdlibinc     -fno-rtti -DBUILDING_LIBART=1 -fno-rtti -std=gnu++11 -ggdb3 -Wall -Werror -Wextra -Wstrict-aliasing -fstrict-aliasing -Wunreachable-code -Wredundant-decls -Wshadow -Wunused -fvisibility=protected -DART_DEFAULT_GC_TYPE_IS_CMS -DIMT_SIZE=64 -DART_TARGET -DART_BASE_ADDRESS=0x70000000 -DART_ENABLE_CODEGEN_arm -DART_ENABLE_CODEGEN_arm64 -DART_ENABLE_CODEGEN_mips -DART_ENABLE_CODEGEN_mips64 -DART_ENABLE_CODEGEN_x86 -DART_ENABLE_CODEGEN_x86_64 -DART_BASE_ADDRESS_MIN_DELTA=-0x1000000 -DART_BASE_ADDRESS_MAX_DELTA=0x1000000 -O3 -Wframe-larger-than=1728 -fPIC -DART_DEFAULT_INSTRUCTION_SET_FEATURES=\"default\" -D_USING_LIBCXX -Wthread-safety -Wthread-safety-negative -Wimplicit-fallthrough -Wfloat-equal -Wint-to-void-pointer-cast -Wused-but-marked-unused -Wdeprecated -Wunreachable-code-break -Wunreachable-code-return -Wmissing-noreturn -std=gnu++14  -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast  -Werror=address-of-temporary -Werror=null-dereference -Werror=return-type    -MD -MF out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/nanoscope_sampler.d -o out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/nanoscope_sampler.o art/runtime/nanoscope_sampler.cc ) && (cp out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/nanoscope_sampler.d out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/nanoscope_sampler.P; sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\\\$//' -e '/^\$/ d' -e 's/\$/ :/' < out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/nanoscope_sampler.d >> out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/nanoscope_sampler.P; rm -f out/target/product/generic_x86_64/obj_x86/SHARED_LIBRARIES/libart_intermediates/nanoscope_sampler.d )"
art/runtime/nanoscope_sampler.cc:134:24: error: stack frame size of 4220 bytes in function 'art::NanoscopeSampler::signal_handler' [-Werror,-Wframe-larger-than=]
void NanoscopeSampler::signal_handler(int sigo ATTRIBUTE_UNUSED, siginfo_t *siginfo ATTRIBUTE_UNUSED, void *ucontext ATTRIBUTE_UNUSED) {
                       ^
1 error generated.```
awelc commented 5 years ago

I fixed this a while ago, but did not realize that my PR hasn't been merged. Shouldn't be a problem anymore.