Skip to content

Conversation

@bitsandfoxes
Copy link
Contributor

@bitsandfoxes bitsandfoxes commented Nov 24, 2025

Resolves #2050

#skip-changelog

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 8cbe91e

@bitsandfoxes bitsandfoxes marked this pull request as ready for review November 26, 2025 14:50
Comment on lines +254 to +255
[DllImport("__Internal")]
private static extern int vsnprintf_il2cpp(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: DllImport for vsnprintf_il2cpp lacks EntryPoint attribute, causing EntryPointNotFoundException and silent failure of native log forwarding on IL2CPP.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The DllImport for vsnprintf_il2cpp at src/Sentry.Unity.Native/SentryNativeBridge.cs lines 254-255 is missing the EntryPoint attribute. The C# method vsnprintf_il2cpp does not match the native C function vsnprintf_sentry. Without EntryPoint, the P/Invoke runtime will fail to find the correct native symbol, leading to an EntryPointNotFoundException on IL2CPP platforms (e.g., PlayStation). Although caught, this exception causes native log forwarding to silently fail, resulting in a loss of critical diagnostic information.

💡 Suggested Fix

Add EntryPoint = "vsnprintf_sentry" to the DllImport attribute for vsnprintf_il2cpp to correctly map the C# method to the native C function.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/Sentry.Unity.Native/SentryNativeBridge.cs#L254-L255

Potential issue: The `DllImport` for `vsnprintf_il2cpp` at
`src/Sentry.Unity.Native/SentryNativeBridge.cs` lines 254-255 is missing the
`EntryPoint` attribute. The C# method `vsnprintf_il2cpp` does not match the native C
function `vsnprintf_sentry`. Without `EntryPoint`, the P/Invoke runtime will fail to
find the correct native symbol, leading to an `EntryPointNotFoundException` on IL2CPP
platforms (e.g., PlayStation). Although caught, this exception causes native log
forwarding to silently fail, resulting in a loss of critical diagnostic information.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4635821


// For IL2CPP: use __Internal which links to the compiled sentry_utils.c
[DllImport("__Internal")]
private static extern int vsnprintf_il2cpp(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: P/Invoke function name mismatch with native C function

The [DllImport("__Internal")] declaration for vsnprintf_il2cpp expects a native function with that exact name, but sentry_utils.c exports the function as vsnprintf_sentry. When using __Internal without an EntryPoint attribute, IL2CPP looks for a function matching the C# method name exactly. This mismatch will cause a linker error when building for IL2CPP platforms. The declaration needs EntryPoint = "vsnprintf_sentry" or the C function needs to be renamed to vsnprintf_il2cpp.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for PlayStation

3 participants