Skip to content

Commit

Permalink
Fix some asan checks and violations (#132)
Browse files Browse the repository at this point in the history
* Exclude asan checks from safe loads

* Update download GH action version

* Enforce aligment for externally provided pointers

* Make wallclock tests retrying
  • Loading branch information
jbachorik authored Sep 24, 2024
1 parent 6e6942d commit c291308
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
if: failure()
steps:
- name: Download failed tests artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: failures
path: ./artifacts
Expand Down
9 changes: 8 additions & 1 deletion ddprof-lib/src/main/cpp/codeCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define _CODECACHE_H

#include <jvmti.h>
#include <stdlib.h>
#include <string.h>
#include <vector>

Expand Down Expand Up @@ -52,7 +53,13 @@ class NativeFunc {
static char *create(const char *name, short lib_index);
static void destroy(char *name);

static short libIndex(const char *name) { return from(name)->_lib_index; }
static short libIndex(const char *name) {
NativeFunc* func = from(name);
if (posix_memalign((void**)(&func), sizeof(NativeFunc*), sizeof(NativeFunc)) != 0) {
return -1;
}
return func->_lib_index;
}

static bool isMarked(const char *name) { return from(name)->_mark != 0; }

Expand Down
9 changes: 5 additions & 4 deletions ddprof-lib/src/main/cpp/safeAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@
#else
#define NOINLINE __attribute__((noinline, noclone))
#endif
#define NOADDRSANITIZE __attribute__((no_sanitize("address")))

class SafeAccess {
public:
NOINLINE __attribute__((aligned(16))) static void *load(void **ptr) {
NOINLINE NOADDRSANITIZE __attribute__((aligned(16))) static void *load(void **ptr) {
return *ptr;
}

NOINLINE __attribute__((aligned(16))) static u32 load32(u32 *ptr,
NOINLINE NOADDRSANITIZE __attribute__((aligned(16))) static u32 load32(u32 *ptr,
u32 default_value) {
return *ptr;
}

NOINLINE __attribute__((aligned(16))) static void *
NOINLINE NOADDRSANITIZE __attribute__((aligned(16))) static void *
loadPtr(void **ptr, void *default_value) {
return *ptr;
}

static uintptr_t skipLoad(uintptr_t pc) {
NOADDRSANITIZE static uintptr_t skipLoad(uintptr_t pc) {
if (pc - (uintptr_t)load < sizeSafeLoadFunc) {
#if defined(__x86_64__)
return *(u16 *)pc == 0x8b48 ? 3 : 0; // mov rax, [reg]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RetryingTest;
import org.openjdk.jmc.common.item.IItem;
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.item.IItemIterable;
Expand All @@ -41,7 +41,7 @@ protected void before() {
methodsToSpanIds = new ConcurrentHashMap<>();
}

@Test
@RetryingTest(5)
public void test() throws ExecutionException, InterruptedException {
Assumptions.assumeTrue(!Platform.isJ9() && !Platform.isZing());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RetryingTest;
import org.openjdk.jmc.common.item.IItem;
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.item.IItemIterable;
Expand All @@ -15,7 +15,7 @@

public class WallClockThreadFilterTest extends AbstractProfilerTest {

@Test
@RetryingTest(5)
public void test() throws InterruptedException {
Assumptions.assumeTrue(!Platform.isJ9());
registerCurrentThreadForWallClockProfiling();
Expand Down

0 comments on commit c291308

Please sign in to comment.