Skip to content

native crash in sample #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Native crash in sample ([#270](https://github.com/getsentry/sentry-unity/pull/270))

### Fixes

- Bump Sentry .NET SDK 3.8.3 ([#269](https://github.com/getsentry/sentry-unity/pull/269))
Expand Down
4 changes: 4 additions & 0 deletions samples/unity-of-bugs/Assets/Plugins/NativeExample.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void crash() {
char *ptr = 0;
*ptr += 1;
}
101 changes: 101 additions & 0 deletions samples/unity-of-bugs/Assets/Plugins/NativeExample.c.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions samples/unity-of-bugs/Assets/Scripts/BugFarm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Assertions;

Expand Down Expand Up @@ -99,20 +100,25 @@ public void ThrowKotlinOnBackground()

public void CrashNative()
{
// The method definition is missing
//crash();
#if !UNITY_EDITOR
crash();
#else
Debug.Log("Requires IL2CPP. Try this on a native player.");
#endif
}

#if !UNITY_EDITOR
// NativeExample.c
[DllImport("__Internal")]
private static extern void crash();
#endif

[MethodImpl(MethodImplOptions.NoInlining)]
private void MethodA() => throw new InvalidOperationException("Exception from A lady beetle 🐞");

// IL2CPP inlines this anyway
[MethodImpl(MethodImplOptions.NoInlining)]
private void MethodB() => MethodA();

// The method definition is missing
//[DllImport("__Internal")]
//private static extern void crash();
}

public class CustomException : System.Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ GraphicsSettings:
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
Expand Down