Skip to content

scala.reflect.io.ZipArchive#ensureDir infinitely recurses in some cases in 2.13.1 #11754

@mjadczak

Description

@mjadczak

It looks like this class was modified in 2.13.1 to use a "path" representation for entries always, instead of going back and forth between "dotted" and "path" representations (see scala/scala#8356). The ensureDir function depends on having a "root" entry already in the dirs map which is passed in - otherwise, it will never terminate, as the dirName function which it calls has a fixed point at "/".

With the "path" representation, the root is always "/", whereas it seems to have been "" in some cases previously. This means that every time we will call this ensureDir functions, we need to make sure that we pass it a map already containing an entry for "/". There seems to have already been an effort to fix some of these cases. Unfortunately, not all were caught.

In our case, we are reflectively compiling scala code at runtime, and are getting a StackOverflowError in this method when resolving one package (javax.swing). I have traced this to this line, which I believe should use "/" as the key, instead of "". I think there is a similar bug at line 250 in that file, in URLZipArchive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions