summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-03-28 22:30:06 -0700
committer Elliott Hughes <enh@google.com> 2012-03-28 22:30:06 -0700
commit448e93c728b352729afde3c8e95e902c08b1d929 (patch)
tree62f1748c09bf8b3e97cf941a3c2cc9afeeceb71b /src
parentf1498437b0d6beb9f4f91980b98cbeb0b5c773ce (diff)
Fix dex2oat on the Mac.
What did we do before valgrind? _NSGetExecutablePath was responsible for the heap corruption. The vmmap(1) parsing was slightly off too. Change-Id: Id458d99c0f75e70a5c59cfbd785ea2efebfbdfce
Diffstat (limited to 'src')
-rw-r--r--src/compiler.cc11
-rw-r--r--src/mem_map.cc4
2 files changed, 5 insertions, 10 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index b3d6367d7f..0bf46731e7 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -270,15 +270,10 @@ static std::string MakeCompilerSoName(InstructionSet instruction_set) {
// On Linux, dex2oat will have been built with an RPATH of $ORIGIN/../lib, so dlopen(3) will find
// the .so by itself. On Mac OS, there isn't really an equivalent, so we have to manually do the
// same work.
- std::vector<char> executable_path(1);
uint32_t executable_path_length = 0;
- _NSGetExecutablePath(&executable_path[0], &executable_path_length);
- while (_NSGetExecutablePath(&executable_path[0], &executable_path_length) == -1) {
- executable_path.resize(executable_path_length);
- }
-
- executable_path.resize(executable_path.size() - 1); // Strip trailing NUL.
- std::string path(&executable_path[0]);
+ _NSGetExecutablePath(NULL, &executable_path_length);
+ std::string path(executable_path_length, static_cast<char>(0));
+ CHECK_EQ(_NSGetExecutablePath(&path[0], &executable_path_length), 0);
// Strip the "/dex2oat".
size_t last_slash = path.find_last_of('/');
diff --git a/src/mem_map.cc b/src/mem_map.cc
index 93f60c431e..62096b1097 100644
--- a/src/mem_map.cc
+++ b/src/mem_map.cc
@@ -87,8 +87,8 @@ void CheckMapRequest(byte* addr, size_t length) {
continue;
}
- std::string start_str(line.substr(22, 8));
- std::string end_str(line.substr(31, 8));
+ std::string start_str(line.substr(23, 8));
+ std::string end_str(line.substr(32, 8));
uint32_t start = ParseHex(start_str);
uint32_t end = ParseHex(end_str);
CheckMapRegion(base, limit, start, end, maps);