2 scripts shouldn't use the same area such as global variable region. I.e., fixed the code right after mmap().
Change-Id: I0fc3f4b9beb24f5e4fc70c72dcbfceb58bf1e813
diff --git a/lib/bcc/Compiler.cpp b/lib/bcc/Compiler.cpp
index 6ab1dd3..752121e 100644
--- a/lib/bcc/Compiler.cpp
+++ b/lib/bcc/Compiler.cpp
@@ -543,10 +543,15 @@
// Update the BccMmapImgAddrTaken table (if required)
if (mCacheHdr->cachedCodeDataAddr >= BCC_MMAP_IMG_BEGIN) {
size_t offset = mCacheHdr->cachedCodeDataAddr - BCC_MMAP_IMG_BEGIN;
+ size_t scriptId = offset / BCC_MMAP_IMG_SIZE;
if ((offset % BCC_MMAP_IMG_SIZE) == 0 &&
- (offset / BCC_MMAP_IMG_SIZE) < BCC_MMAP_IMG_COUNT) {
- Compiler::BccMmapImgAddrTaken[offset / BCC_MMAP_IMG_SIZE] = true;
+ scriptId < BCC_MMAP_IMG_COUNT) {
+ if (Compiler::BccMmapImgAddrTaken[scriptId] == true) {
+ mCodeDataAddr = (char *) MAP_FAILED;
+ } else {
+ Compiler::BccMmapImgAddrTaken[scriptId] = true;
+ }
}
}