Skip to content

Commit c999f5a

Browse files
jpnurmiclaude
andauthored
test(android): Use volatile to produce SIGSEGV in native crash test (#4919)
* test(android): Use volatile to produce SIGSEGV in native crash test The null-pointer dereference was undefined behavior that the compiler optimized into a trap instruction, producing SIGILL (x86_64) or SIGTRAP (arm64) instead of a real crash. Adding volatile forces an actual memory access, resulting in a consistent SIGSEGV across architectures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: Skip buildnative on runners with NO_MOBILE The buildnative action builds Android-specific supplemental libraries that are only needed by Sentry.Bindings.Android. On linux-arm64 and other NO_MOBILE runners, the solution filter excludes that project, so building native deps is unnecessary and fails (no Android NDK). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: Fix JAVA_HOME_11 selection for ARM64 runners Select JAVA_HOME_11 based on runner architecture instead of OS. The previous check only used ARM64 for macOS, leaving Windows ARM64 with the empty X64 variant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 69d4a06 commit c999f5a

File tree

8 files changed

+7
-4
lines changed

8 files changed

+7
-4
lines changed

.github/actions/buildnative/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
- name: Set Environment Variables
99
shell: bash
1010
run: |
11-
if [[ "$RUNNER_OS" == "macOS" ]]; then
11+
if [[ "$RUNNER_ARCH" == "ARM64" ]]; then
1212
echo "JAVA_HOME_11=$JAVA_HOME_11_ARM64" >> $GITHUB_ENV
1313
else
1414
echo "JAVA_HOME_11=$JAVA_HOME_11_X64" >> $GITHUB_ENV

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ jobs:
197197
enableCrossOsArchive: true
198198

199199
- name: Build Native Dependencies
200-
if: ${{ !matrix.container }}
200+
if: ${{ !matrix.container && !env.NO_MOBILE }}
201201
uses: ./.github/actions/buildnative
202202

203203
- name: Restore .NET Dependencies
@@ -372,6 +372,7 @@ jobs:
372372
uses: ./.github/actions/environment
373373

374374
- name: Build Native Dependencies
375+
if: ${{ !env.NO_MOBILE }}
375376
uses: ./.github/actions/buildnative
376377

377378
- name: Fetch NuGet Packages

integration-test/android.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Describe 'MAUI app (<dotnet_version>, <configuration>)' -ForEach $cases -Skip:(-
162162

163163
Dump-ServerErrors -Result $result
164164
$result.HasErrors() | Should -BeFalse
165-
$result.Events() | Should -AnyElementMatch "`"type`":`"SIG[A-Z]+`"" # SIGILL (x86_64), SIGTRAP (arm64-v8a)
165+
$result.Events() | Should -AnyElementMatch "`"type`":`"SIGSEGV`""
166166
$result.Events() | Should -Not -AnyElementMatch "`"type`":`"System.\w+Exception`""
167167
$result.Events() | Should -HaveCount 1
168168
}
144 Bytes
Binary file not shown.
220 Bytes
Binary file not shown.
304 Bytes
Binary file not shown.
88 Bytes
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
__attribute__((noinline))
22
void crash()
33
{
4-
char *ptr = 0;
4+
// volatile prevents the compiler from optimizing the null dereference (UB) into
5+
// a trap instruction (SIGILL/SIGTRAP) and forces an actual SIGSEGV instead.
6+
volatile char *ptr = 0;
57
*ptr += 1;
68
}

0 commit comments

Comments
 (0)