Skip to content

Fix cyclic reference errors in collection strawman #2914

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

Merged
merged 4 commits into from
Aug 2, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 25, 2017

This should make collection strawman #137 build. There were some "interesting" F-bounded types which triggered a series of problems when read back with Tasty unpicklers. First, the underlying error message ("wrong number of arguments") was hidden because it caused a CRE. Next, the wrong number of argument problems demanded that we are more careful reading applicatons. Once that was done we got Stackoverflows. To avoid these, we have to maintain any LazyRefs we have in the original types in the pickle information.

Review by @szeiger or @julienrf?

odersky added 3 commits July 25, 2017 20:18
Need to keep cycle breakers
Same principle as reading from Scala2 pickles applied = in the face
of F-bounded polymorphism we cannot assume that the type
parameters are known when we unpickle a type application.
val rdr = fork
def readUnderlying() = rdr.readType()
skipTree()
LazyRef(readUnderlying)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means LazyRefs will keep the context from which they were unpickled around, if these LazyRefs are subsequently stored in some cache, that could lead to space leaks, no?

Copy link
Contributor Author

@odersky odersky Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct. Maybe the best option is to allow a context to be passed into a LazyRef completer. In the case of unpickling, this is fine; we don't need to hang on to more than the reader (I think, at least that's what we do for the other completers).

case symbol => symbol.showFullName
}
catch {
case NonFatal(ex) => fntpe.show
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is only for cyclic references, could we do case ex: CyclicReference instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we by default we should not throw any exception from printing. It detracts from the underlying cause.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we shouldn't be throwing any kind of exceptions, and silently catching them all might hide issues.

@DarkDimius
Copy link
Contributor

@odersky, instead of pickling lazy refs, could we create them at un-pickling similarly to how we create them at typer?

@odersky
Copy link
Contributor Author

odersky commented Jul 25, 2017

@odersky, instead of pickling lazy refs, could we create them at un-pickling similarly to how we create them at typer?

I tried that, but it didn't help. Did not get to find out why. Anyway, pickling LazyRefs is more efficient than re-scanning types to reconstruct them.

This avoids memory leaks in unpicklers, where lazy refs
don't capture the context anymore. Other lazyrefs still need
to capture context, though.
@odersky
Copy link
Contributor Author

odersky commented Aug 2, 2017

Merging now to get the strawman unstuck, but I opened an issue to revert the LazyRef addition if possible. /cc @julienrf

@odersky odersky merged commit 4dc27d2 into scala:master Aug 2, 2017
@julienrf
Copy link
Contributor

julienrf commented Aug 2, 2017

Thanks @odersky!

@allanrenucci allanrenucci deleted the fix-cyclic-refs-strawman branch December 14, 2017 19:20
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

Successfully merging this pull request may close these issues.

4 participants