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

Support for JARs with size greater than 2 Gigs #522

Open
rizistt opened this issue May 4, 2024 · 5 comments
Open

Support for JARs with size greater than 2 Gigs #522

rizistt opened this issue May 4, 2024 · 5 comments

Comments

@rizistt
Copy link

rizistt commented May 4, 2024

Currently the method WriteResources under IKVM.Tools.Importer.CompilerClassLoader uses MemoryStream which is limited to 2 gigs in size whereas I'm working with JAR files (that contain CUDA dlls) having size greater than 2 gigs which causes IO_StreamTooLong exception.

Are there any workarounds?

@rizistt rizistt changed the title Support for JAR with size greater than 2 Gigs Support for JARs with size greater than 2 Gigs May 4, 2024
@rizistt
Copy link
Author

rizistt commented May 4, 2024

Turns out it's not really a limitation of IKVM at all. I changed the MemoryStream to FileStream in the WriteResources method and got this:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'mappedFieldDataStreamRva')
    at System.Reflection.Throw.ArgumentOutOfRange(String parameterName)
    at System.Reflection.Metadata.Ecma335.MetadataRootBuilder.Serialize(BlobBuilder builder, Int32 methodBodyStreamRva, Int32 mappedFieldDataStreamRva)	

@wasabii
Copy link
Contributor

wasabii commented May 4, 2024

Taking a deeper look, there's probably a hard limit of 3 or 2 GB for .NET assembly sizes as well, at least on Windows, as they are PE files, and ultimately loaded with LoadLibrary.

I don't have a workaround for you other than to not put this particular data in a JAR, etc.

@rizistt
Copy link
Author

rizistt commented May 4, 2024

Thank you for your response, @wasabii. As a workaround what I did was to modify the Jar itself and split it into 2 Jars and changed the metadata and got it working, I haven't fully tested it but it seems to be working. Unfortunately, I am not the author of those packages (yes it's more than 2 source packages and around 4 gigs in size) so I have very little control over what I can do with them.

@wasabii
Copy link
Contributor

wasabii commented May 4, 2024

As a feature, it might be useful to have the ability for ikvmc to generate assemblies with external resources as files or something.

@rizistt
Copy link
Author

rizistt commented May 4, 2024

It's actually a great idea.

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

No branches or pull requests

2 participants