Skip to content
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

RandomNumberGenerator.GetInt32 throws DllNotFoundException on iOS #3505

Closed
PieEatingNinjas opened this issue Nov 22, 2021 · 3 comments
Closed
Labels
platform/iOS 🍎 t/bug Something isn't working

Comments

@PieEatingNinjas
Copy link
Contributor

Description

When using System.Security.Cryptography.RandomNumberGenerator.GetInt32 on iOS a DLLNotFoundException is thrown.

Exception message: libcoreclr.so
Stacktrace:

   at Interop.AppleCrypto.GetRandomBytes(Byte* pbBuffer, Int32 count) in System.Security.Cryptography.Algorithms.dll:token 0x600002e+0x0
   at System.Security.Cryptography.RandomNumberGeneratorImplementation.GetBytes(Byte* pbBuffer, Int32 count) in System.Security.Cryptography.Algorithms.dll:token 0x60001c3+0x0
   at System.Security.Cryptography.RandomNumberGeneratorImplementation.FillSpan(Span`1 data) in System.Security.Cryptography.Algorithms.dll:token 0x60001bd+0x15
   at System.Security.Cryptography.RandomNumberGenerator.GetInt32(Int32 fromInclusive, Int32 toExclusive) in System.Security.Cryptography.Algorithms.dll:token 0x60001e3+0x4b
   at System.Security.Cryptography.RandomNumberGenerator.GetInt32(Int32 toExclusive) in System.Security.Cryptography.Algorithms.dll:token 0x60001e4+0x14

No problems on Android or Windows.

Take a look at the Repro.

Steps to Reproduce

  1. Create new MAUI project
  2. Add using Microsoft.Maui.Hosting; in AppDelegate.cs
  3. Add the following code to the constuctor of MainPage var x = RandomNumberGenerator.GetInt32(10);
  4. See it crash when running the app on iOS

Tested on physical iPhone via Hot Restart.

Version with bug

Preview 10 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15.1

Did you find any workaround?

Using new Random().Next to generate a random number.

Relevant log output

[0:] An error occurred: 'libcoreclr.so'. Callstack: '   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004f51+0x6a'
The app has been terminated.
@PieEatingNinjas PieEatingNinjas added the t/bug Something isn't working label Nov 22, 2021
@Eilon
Copy link
Member

Eilon commented Nov 29, 2021

Looks like the same root issue as #3406.

@Eilon
Copy link
Member

Eilon commented Dec 7, 2021

Looks like this was fixed for .NET 6 RC1 as part of this PR: xamarin/xamarin-macios#12323 (I followed a trail starting at dotnet/runtime#58185)

@Eilon Eilon closed this as completed Dec 7, 2021
@Eilon
Copy link
Member

Eilon commented Dec 7, 2021

BTW if for some reason this still occurs on the most recent builds, please file an issue at https://github.com/xamarin/xamarin-macios with the details and versions you are running.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants