Skip to content

Commit

Permalink
Avoid membarrier on lower Android versions (#92686)
Browse files Browse the repository at this point in the history
Hopefully fixes #92196.

I don't actually have an ARM64 device with an old Android version so I can't testing it actually fixes the problem, but it's a plausible fix.
  • Loading branch information
MichalStrehovsky authored Sep 27, 2023
1 parent 377fa6c commit c3b1ed0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ enum membarrier_cmd

bool CanFlushUsingMembarrier()
{

#ifdef TARGET_ANDROID
// Avoid calling membarrier on older Android versions where membarrier
// may be barred by seccomp causing the process to be killed.
int apiLevel = android_get_device_api_level();
if (apiLevel < __ANDROID_API_Q__)
{
return false;
}
#endif

// Starting with Linux kernel 4.14, process memory barriers can be generated
// using MEMBARRIER_CMD_PRIVATE_EXPEDITED.

Expand Down

0 comments on commit c3b1ed0

Please sign in to comment.