-
Notifications
You must be signed in to change notification settings - Fork 54
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
Fix il2cpp error (take 2) #548
Conversation
This reverts commit ba4555e.
Previous commit about this issue reverted since it wasn't fixing the issue. The actual error was: Error: IL2CPP error for method 'System.Char[] NATS.Client.Core.Internal.NuidWriter::Refresh(System.UInt64&)' in assembly NATS.Client.Core.dll System.ArgumentOutOfRangeException: Cannot create a constant value for types of System.UIntPtr for System.UIntPtr NATS.Client.Core.Internal.NuidWriter::NuidLength (Parameter 'declaredParameterOrFieldType') Looking at Unsafe.Add examples passing in uint or int instead of nuint is fine: e.g. https://github.com/dotnet/runtime/blob/a7efcd9ca9255dc9faa8b4a2761cdfdb62619610/src/libraries/System.Private.CoreLib/src/System/Buffer.cs#L84 Note: I had to revert the last two commits (so ignore the previous four commits) to main which was done by mistake without PRs.
For the sake of general review and future doc ; what are all of the 'conditions' we had to fix or deal with? I think this would be good for general doc as well as putting together for future 'contributor guidelines' to help with knowing how to do the needful with IL2CPP As it stands, I don't have bandwidth to test locally so will refrain from any approval but will take a look. <3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK but per other comments we should doc what we are learning along the way.
{ | ||
internal const nuint NuidLength = PrefixLength + SequentialLength; | ||
private const nuint Base = 62; | ||
internal const uint NuidLength = PrefixLength + SequentialLength; | ||
private const uint Base = 62; | ||
private const ulong MaxSequential = 839299365868340224; // 62^10 | ||
private const uint PrefixLength = 12; | ||
private const nuint SequentialLength = 10; | ||
private const uint SequentialLength = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I think this is probably better for comprehension sake anyway (i.e. scoping/etc)
To elaborate a bit more: in the previous PR #543 I wrongly thought the IL2CPP error was caused by the inner method local reuse and my oversight in testing in Unity for some reason I thought it was fixing the issue. But after the preview release trying it again in a fresh unity project I realized the compile error was still there for Linux IL2CPP builds. Looking at the error more closely it looks like IL2CPP can't deal with Also to note, fairly extensive tests for NuidWrite are passing as well:
As shown above in the main description local testing of Unity build completed successfully proving the fix works. |
Yeah, I think I saw something related to this when |
@to11mtm, @stebet, @rickdotnet, @caleblloyd sorry to pull you all in, it'd be good to have more eyes on this PR. It's a simple change but because of my wrong fix then a revert it became a little messy. Tha change is very simple actually. Before the change second parameter of I feel this is good since tests are passing as well. Not sure how much more validation we can do. Let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Fix il2cpp error (take 2) (#548)
* Fix il2cpp error (take 2) (#548)
@mtmk This looks good too :) The change from |
Previous commit about this issue reverted since it wasn't fixing the issue. The actual error was:
With this fix now it compiles fine:
Looking at Unsafe.Add examples passing in uint or int instead of nuint is fine:
e.g. https://github.com/dotnet/runtime/blob/a7efcd9ca9255dc9faa8b4a2761cdfdb62619610/src/libraries/System.Private.CoreLib/src/System/Buffer.cs#L84
Note: I had to revert the last two commits (so ignore the previous four commits) to main which was done by mistake without PRs.
cc @galvesribeiro