Commit graph

20 commits

Author SHA1 Message Date
Vyacheslav Egorov 18bdb28ef6 [vm/profiler] On Android use alternative stack for handling SIGPROF.
Bionic implementation of setjmp mangles[1] stack pointer - which means
it is unsafe to handle signals on the thread stack (see b/152210274).

Thread interrupter is constantly sending SIGPROF to the Dart thread -
which means with a small probability it might hit the case when we are
inside setjmp. If SP is mangled it might point to random writable memory
or to non-writable region. In the first case we will get a very obscure
memory corruption, and in the second case kernel would send us SIGSEGV
because it fails to deliver original signal.

This bug is the source of the numerous mysterious crashes reported for Flutter,
looking like this:

  F/libc    (11547): Fatal signal 11 (SIGSEGV), code 128, fault addr 0x0 in tid 11572 (1.ui), pid 11547 (ectivity_change)
  ...
  signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0
  ...
  backtrace:
      #00 pc 00018abc  /system/lib/libc.so (sigsetjmp+120)

Note the following key points: SIGSEGV has code SI_KERNEL (meaning it
was triggered by kernel - rather than by a hardware fault) and the first
and only frame is inside sigsetjmp (unwinding is obviously also broken
because SP is mangled).

Fixes https://github.com/flutter/flutter/issues/27077

[1] https://android.googlesource.com/platform/bionic/+/refs/heads/master/libc/arch-x86/bionic/setjmp.S#132

Change-Id: I91afa42dbf6575db0cce8e223368b857a49b39b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140643
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-03-23 21:49:37 +00:00
Zichang Guo 1509d9ad41 [vm] initialize sigaction for msan
msan didn't recognize instance initialized with memset or bzero. Initialize all the instances.

Bug: https://buganizer.corp.google.com/issues/137630695
Change-Id: I0f4adf90cd9d4daa2abe783b1e1ca892bdacb690
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109306
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2019-07-16 19:46:56 +00:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Ryan Macnak daa38a2ea2 [profiler, linux/android] Check whether a sample is ARM or Thumb code to decide which FP register to load.
Android and Linux use R11 as the FP register in ARM code and R7 in Thumb code. We've been assuming all code in our process is ARM and reading R11 as FP. This made our stack walks fail if they started in Thumb code.

This issue does not arise on iOS, because its ABI uses R7 as the FP register for both ARM and Thumb code.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2965823002 .
2017-07-05 09:43:12 -07:00
Ryan Macnak 877284947b Rename TARGET_OS_* to HOST_OS_*.
Like HOST_ARCH_*, HOST_OS_* describes the OS the VM is running on, which may be different from the OS the VM is generating code for during AOT compilation.

Currently we conflate the two when emitting AOT as assembly, and we get away with it because Flutter only uses assembly for targeting iOS and one can only target iOS from a Mac, but we expect to use assembly for Android as well so native tools can unwind Dart frames.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2750843003 .
2017-03-15 13:11:05 -07:00
Ryan Macnak d4e1f13644 Fix profiler access to the Dart stack pointer on ARM64.
Cf. 642f754219.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2184903002 .
2016-07-26 16:59:16 -07:00
Vyacheslav Egorov b089d4f004 Work around a kernel bug on Android.
Kernel does not clear If-Then execution state bits when entering ARM signal handler which violates requirements imposed by ARM architecture reference. Some CPUs look at these bits even while in ARM mode which causes them
to skip some instructions in the prologue of the signal handler.

To work around the issue we insert enough NOPs in the prologue to ensure that no actual instructions are skipped and then branch to the actual signal handler.

For the kernel patch that fixes the issue see: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6ecf830e5029598732e04067e325d946097519cb

This causes sporadic crashes with SIGILL on some testing devices (e.g. Nexus 7).

R=fschneider@google.com
BUG=

Review URL: https://codereview.chromium.org/1940883002 .
2016-05-02 19:12:48 +02:00
Zachary Anderson 7c2c02d6a6 Fix x86-64 Android build.
R=iposva@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1761953002 .
2016-03-03 11:11:31 -08:00
Ryan Macnak 6d3bb00887 Fix profiling on ARM64.
Linux/Android broken in 91bc8005fe.

iOS was unimplemented.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1428893003 .
2015-10-30 09:26:24 -07:00
Zachary Anderson 1051b3e65a Fix ia32 android build
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1184673005.
2015-06-15 08:53:41 -07:00
Ivan Posva 8f1506e817 - Determine whether the simulator is being used in globals.h
- Make sure to switch on HOST_ARCH_ and on USING_SIMULATOR
  where appropriate.
- Avoid allocating in new generation when running in the VM isolate.

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1156053006
2015-05-29 14:35:29 -07:00
rmacnak@google.com f5146670c6 Fix unsimulated ARM64 build.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1105263003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45434 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-27 22:16:53 +00:00
johnmccutchan@google.com afe774a4c4 Remove profiler signal handler on shutdown
BUG=https://github.com/domokit/mojo/issues/79
R=asiva@google.com

Review URL: https://codereview.chromium.org//1061033005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44943 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-07 18:33:01 +00:00
johnmccutchan@google.com f2333f63a5 Add Function based profile tree
Profiler improvements:
- Track Functions in profile and build Function based trie
- Associate code objects with functions
- Created cpu_profile.dart library
- Major speed improvements for disassembly view
- Fix truncation of disassembly comments
- Ability to get code object ticks from disassembly view
- Inlining mini-map in disassembly view.
- Remove a bunch of unused data from profile service response
- In some cases a caller PC that is better than the PC marker is inserted into the stack trace
- Inlined functions are expanded
- Ability to clear profile
- New flag '--keep_code' which keeps deoptimized code around for use by the profiler.

General fixes:
- Fix caching in service library
- Remove pubspec.yaml before running pub get

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org//928833003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44067 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-26 18:48:55 +00:00
zra@google.com 816bf5af2e Fixes for the profiler on arm64.
On arm64, in Dart code, R18(SP) is the stack pointer.
In C++ code, R31(CSP) is the stack pointer.
The profiler must choose the right one when performing
its bounds checks.

This change also fixes a bug in the InvokeDartCode stub
on arm64 so that CSP is set to the Isolate's stack
limit immediately, rather than a bit later. When it was
set a bit later, if a profiler interrupt came in in the
interim, the stack would be smashed.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//583683002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40502 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-19 16:25:16 +00:00
zra@google.com ec1140b188 Adds support for building arm64 Android.
R=regis@google.com

Review URL: https://codereview.chromium.org//539573003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39844 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-03 23:31:51 +00:00
zra@google.com 37baacb116 Small fixes for Android.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//254383003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35342 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-23 23:20:24 +00:00
johnmccutchan@google.com 919dc2d6eb * Introduce ThreadInterrupter which calls a TLS set callback when thread is interrupted.
* Threads can only register and unregister themselves with ThreadInterrupter.
* Profiler is no longer involved in interrupting threads. It's just a callback and the buffer.
* Profiler operates lock free using an atomic operation to reserve sample in sample buffer.
* Linux, Mac, and Windows done.

R=asiva@google.com

Review URL: https://codereview.chromium.org//109803002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31170 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-16 18:52:15 +00:00
johnmccutchan@google.com 3a088e89dd Fix Android build ?
BUG=

Review URL: https://codereview.chromium.org//76723003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30431 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-20 00:14:40 +00:00
johnmccutchan@google.com 97ac18aee9 Sampling profiler
BUG=4350
R=asiva@google.com

Review URL: https://codereview.chromium.org//25909002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30419 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-19 18:26:10 +00:00