Commit graph

6 commits

Author SHA1 Message Date
Christopher Ferris
df683b7439 Fix support finding global variables.
The code was not properly getting the variable addresses and using
the offset and address fields of the .data section.

Fix all of that, and update the tests.

Bug: 145162678

Test: Unit tests pass.
Test: ./art/test/run-test --dex2oat-jobs 4 --host --prebuild --compact-dex-level fast --jit --no-relocate --runtime-option -Xcheck:jni  137-cfi
Test: ./art/test/testrunner/testrunner.py -t 137 --host
Change-Id: Ic61c4487334fd2273cda9c56eb1a3b525a03edb7
2019-12-03 17:35:00 -08:00
Florian Mayer
3d67d347f5 Fix copy / move behaviour of Maps object.
Currently, moving or copying a Maps object leads to double free of MapInfo.

Even moving a Maps object  did not prevent this, as after a move
the object only has to be in an "unspecified but valid state", which can
be the original state for a vector of raw pointers (but not for a vector
of unique_ptrs).

Changing to unique_ptrs is the most failsafe way to make sure we never
accidentally destruct MapInfo.

Test: atest libuwindstack_test
      Failed LocalUnwinderTest#unwind_after_dlopen which also fails at master.

Change-Id: Id1c9739b334da5c1ba532fd55366e115940a66d3
2019-03-05 13:05:36 +00:00
Florian Mayer
3f1f2e07ab Add missing includes.
Test: Builds.
Change-Id: Ia8b79154902503cdd774dc3b4523466123b4324c
2018-12-06 10:09:20 -08:00
Christopher Ferris
4568f4bc0f Verify that the elf matches the expected arch.
To avoid a case where a malicious app might try and trick the system to
create an elf and register object that mismatches, always verify that they
are the same arch.

Test: Ran unit tests.
Change-Id: I66978e9e02f8e4f396856912e7019528ead4838e
2018-10-29 18:08:09 -07:00
Christopher Ferris
e8c4ecf49e Always init gnu_debugdata interface if it exists.
Every real call always sets the value to true to init the gnu_debugdata
interface, so remove this parameter.

Test: Builds, unit tests pass.
Change-Id: I07fb3adbbd5b65b51c0dc7608561e820a5095051
2018-10-23 12:13:54 -07:00
Christopher Ferris
56d0e07d70 Fix which maps to search for globals.
If multiple threads are unwinding at the same time, new maps that contain
the global variables for dex files and jit information are created. This
leads to threads creating more new maps that then get searched, then
more maps, then more searching until virtual address space exhaustion.

Fix this so that we only search maps that have a corresponding rw map that
could contain the global memory.

Small refactor to combine the code to search for global variables into
one class that both classes inherit from.

Modify unit tests for the new pattern checking.

Bug: 117761427

Test: Ran unit tests for libunwindstack/libbacktrace/simpleperf.
Test: Ran art 004-ThreadStress that used to fail.
Change-Id: I837ca6b9d0383100079de090bc7d019598e0cdfe
2018-10-17 14:23:10 -07:00