scala/scala-asm-legacy

items[] size in ClassWriter is too small for large scala sources

mdedetrich opened this issue · 7 comments

Scala compiler is crashing with the following stacktrace https://gist.github.com/mdedetrich/069a9b506eb6b7ff01ed

This line appears to be causing the issue https://github.com/scala/scala-asm/blob/master/src/main/java/scala/tools/asm/ClassWriter.java#L611, it seems that statically setting the size of the array to 256 is too small for the size of the Scala source being analyzed

There is already an issue on this for Scalac, so I am not sure if thats a better place to manage the issue (see https://issues.scala-lang.org/browse/SI-9391)

The array items is dynamically resized each time it fills up.

Your stack trace shows that the AIOOBE you see was actually triggered while we were trying to raise the "Method xyz code too large" exception.

It would be helpful if you could share the generated source code, or a SBT project that triggers the error. That would help us to precisely figure out why the name entry is no longer present within the constant pool when we are at that point. (My only guess is that some array index computation is overflowing around Int.MaxValue, but that seems unlikely, even for enormous sources!)

@retronym, I had to upload the SBT project to dropbox, the generated scala sources are 31 megs in size, however the entire project is around 250 megs. Zipped up its 50 megs

The sources for the project are however private (we can't share them publicly), but I can email you the dropbox link, can you message me your email so I can share it on privately on dropbox.

EDIT:
I have left the project since the last stage of compile, so you shouldn't need to recompile the entire project. If you just hit compile in SBT it should work, but if it doesn't, you may need to clean (in which case it takes around 3-5 hours to convert the .wsdl files to .scala)

Hmm, it appears that private messaging no longer exists on github, I will message you on gitter.im

Hi @mdedetrich, this fork of asm has a patch to show the method name in the exception message if a method is too long: scala/scala-asm@5fe5b3b. This patch is buggy if there's a collision in the items hash table, i'll prepare a fix.

Cool thanks, is there visibility as to when it will be merged into the next scala release?

cut a new release with this fix (5.0.4-scala-3, will appear on maven central soon)