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

Crash when snapshot/freshCopy appears in pure inner functions specs #1269

Closed
mario-bucev opened this issue May 25, 2022 · 0 comments · Fixed by #1277
Closed

Crash when snapshot/freshCopy appears in pure inner functions specs #1269

mario-bucev opened this issue May 25, 2022 · 0 comments · Fixed by #1277

Comments

@mario-bucev
Copy link
Collaborator

The following snippet causes a crash:

import stainless._
import stainless.lang._
import StaticChecks._

object SnapshotInSpecs {
  case class Box(var value: Int)

  def outer(b: Box): Unit = {
    require(b.value == 123)

    def inner1: Unit = ().ensuring(_ => snapshot(b).value == 123)
    
    /*
    // Same here as well
    def inner2(v: Int): Unit = {
      require(snapshot(b).value == v)
    }
    */
  }
}

Only pure inner functions are affected.
(Note: here the snapshot is pointless, but in some cases, it is necessary for the anti-aliasing to be happy)

Stacktrace
java.util.NoSuchElementException: key not found: class stainless.extraction.imperative.Trees$LetVar
	at scala.collection.immutable.BitmapIndexedMapNode.apply(HashMap.scala:635)
	at scala.collection.immutable.BitmapIndexedMapNode.apply(HashMap.scala:633)
	at scala.collection.immutable.HashMap.apply(HashMap.scala:132)
	at inox.ast.TreeDeconstructor.deconstruct(Deconstructors.scala:416)
	at inox.ast.TreeDeconstructor.deconstruct$(Deconstructors.scala:21)
	at stainless.extraction.oo.ConcreteTreeDeconstructor.stainless$ast$TreeDeconstructor$$super$deconstruct(Trees.scala:486)
	at stainless.ast.TreeDeconstructor.deconstruct(Deconstructors.scala:194)
	at stainless.ast.TreeDeconstructor.deconstruct$(Deconstructors.scala:6)
	at stainless.extraction.oo.ConcreteTreeDeconstructor.stainless$extraction$innerfuns$TreeDeconstructor$$super$deconstruct(Trees.scala:486)
	at stainless.extraction.innerfuns.TreeDeconstructor.deconstruct(Trees.scala:168)
	at stainless.extraction.innerfuns.TreeDeconstructor.deconstruct$(Trees.scala:114)
	at stainless.extraction.oo.ConcreteTreeDeconstructor.stainless$extraction$oo$TreeDeconstructor$$super$deconstruct(Trees.scala:486)
	at stainless.extraction.oo.TreeDeconstructor.deconstruct(Trees.scala:443)
	at stainless.extraction.oo.TreeDeconstructor.deconstruct$(Trees.scala:426)
	at stainless.extraction.oo.ConcreteTreeDeconstructor.deconstruct(Trees.scala:486)
	at inox.transformers.Transformer.transform(Transformer.scala:52)
	at inox.transformers.Transformer.transform$(Transformer.scala:6)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.transformers.Transformer.transform(Transformer.scala:63)
	at stainless.transformers.Transformer.transform$(Transformer.scala:8)
	at stainless.extraction.oo.ConcreteTreeTransformer.inox$transformers$TreeTransformer$$super$transform(Trees.scala:518)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:220)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.imperative.ImperativeCleanup$TransformerContext.transform(ImperativeCleanup.scala:98)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:221)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at inox.transformers.Transformer.$anonfun$4(Transformer.scala:70)
	at scala.collection.immutable.List.map(List.scala:246)
	at scala.collection.immutable.List.map(List.scala:79)
	at inox.transformers.Transformer.transform(Transformer.scala:73)
	at inox.transformers.Transformer.transform$(Transformer.scala:6)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.transformers.Transformer.transform(Transformer.scala:63)
	at stainless.transformers.Transformer.transform$(Transformer.scala:8)
	at stainless.extraction.oo.ConcreteTreeTransformer.inox$transformers$TreeTransformer$$super$transform(Trees.scala:518)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:220)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.imperative.ImperativeCleanup$TransformerContext.transform(ImperativeCleanup.scala:98)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:221)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at inox.transformers.Transformer.$anonfun$4(Transformer.scala:70)
	at scala.collection.immutable.List.map(List.scala:246)
	at scala.collection.immutable.List.map(List.scala:79)
	at inox.transformers.Transformer.transform(Transformer.scala:73)
	at inox.transformers.Transformer.transform$(Transformer.scala:6)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.transformers.Transformer.transform(Transformer.scala:63)
	at stainless.transformers.Transformer.transform$(Transformer.scala:8)
	at stainless.extraction.oo.ConcreteTreeTransformer.inox$transformers$TreeTransformer$$super$transform(Trees.scala:518)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:220)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.imperative.ImperativeCleanup$TransformerContext.transform(ImperativeCleanup.scala:98)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:221)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at inox.transformers.Transformer.$anonfun$4(Transformer.scala:70)
	at scala.collection.immutable.List.map(List.scala:250)
	at scala.collection.immutable.List.map(List.scala:79)
	at inox.transformers.Transformer.transform(Transformer.scala:73)
	at inox.transformers.Transformer.transform$(Transformer.scala:6)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.transformers.Transformer.transform(Transformer.scala:63)
	at stainless.transformers.Transformer.transform$(Transformer.scala:8)
	at stainless.extraction.oo.ConcreteTreeTransformer.inox$transformers$TreeTransformer$$super$transform(Trees.scala:518)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:220)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.imperative.ImperativeCleanup$TransformerContext.transform(ImperativeCleanup.scala:98)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:221)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at inox.transformers.Transformer.$anonfun$4(Transformer.scala:70)
	at scala.collection.immutable.List.map(List.scala:246)
	at scala.collection.immutable.List.map(List.scala:79)
	at inox.transformers.Transformer.transform(Transformer.scala:73)
	at inox.transformers.Transformer.transform$(Transformer.scala:6)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.transformers.Transformer.transform(Transformer.scala:63)
	at stainless.transformers.Transformer.transform$(Transformer.scala:8)
	at stainless.extraction.oo.ConcreteTreeTransformer.inox$transformers$TreeTransformer$$super$transform(Trees.scala:518)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:220)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.imperative.ImperativeCleanup$TransformerContext.transform(ImperativeCleanup.scala:98)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:221)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at inox.transformers.Transformer.$anonfun$4(Transformer.scala:70)
	at scala.collection.immutable.List.map(List.scala:250)
	at scala.collection.immutable.List.map(List.scala:79)
	at inox.transformers.Transformer.transform(Transformer.scala:73)
	at inox.transformers.Transformer.transform$(Transformer.scala:6)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.stainless$transformers$Transformer$$super$transform(Trees.scala:518)
	at stainless.transformers.Transformer.transform(Transformer.scala:63)
	at stainless.transformers.Transformer.transform$(Transformer.scala:8)
	at stainless.extraction.oo.ConcreteTreeTransformer.inox$transformers$TreeTransformer$$super$transform(Trees.scala:518)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:220)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.imperative.ImperativeCleanup$TransformerContext.transform(ImperativeCleanup.scala:98)
	at inox.transformers.TreeTransformer.transform(Transformer.scala:221)
	at inox.transformers.TreeTransformer.transform$(Transformer.scala:204)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at inox.transformers.DefinitionTransformer.transform(Transformer.scala:181)
	at inox.transformers.DefinitionTransformer.transform$(Transformer.scala:170)
	at stainless.extraction.oo.ConcreteTreeTransformer.transform(Trees.scala:518)
	at stainless.extraction.SimplePhase.extractFunction(ExtractionPipeline.scala:153)
	at stainless.extraction.SimplePhase.extractFunction$(ExtractionPipeline.scala:147)
	at stainless.extraction.imperative.ImperativeCleanup.extractFunction(ImperativeCleanup.scala:140)
	at stainless.extraction.imperative.ImperativeCleanup.extractFunction(ImperativeCleanup.scala:126)
	at stainless.extraction.CachingPhase.$anonfun$3$$anonfun$1(ExtractionPipeline.scala:102)
	at stainless.extraction.utils.ConcurrentCache.cached(ConcurrentCaches.scala:26)
	at stainless.extraction.ExtractionCaches$ExtractionCache.cached(ExtractionCaches.scala:165)
	at stainless.extraction.CachingPhase.$anonfun$1(ExtractionPipeline.scala:102)
	at scala.collection.Iterator$$anon$9.next(Iterator.scala:575)
	at scala.collection.immutable.List.prependedAll(List.scala:156)
	at scala.collection.immutable.List$.from(List.scala:684)
	at scala.collection.immutable.List$.from(List.scala:681)
	at scala.collection.IterableFactory$Delegate.from(Factory.scala:288)
	at scala.collection.immutable.Iterable$.from(Iterable.scala:35)
	at scala.collection.immutable.Iterable$.from(Iterable.scala:32)
	at scala.collection.IterableFactory$Delegate.from(Factory.scala:288)
	at scala.collection.IterableOps.map(Iterable.scala:671)
	at scala.collection.IterableOps.map$(Iterable.scala:671)
	at scala.collection.AbstractIterable.map(Iterable.scala:919)
	at stainless.extraction.CachingPhase.extractSymbols(ExtractionPipeline.scala:102)
	at stainless.extraction.CachingPhase.extractSymbols$(ExtractionPipeline.scala:82)
	at stainless.extraction.imperative.ImperativeCleanup.stainless$extraction$oo$CachingPhase$$super$extractSymbols(ImperativeCleanup.scala:17)
	at stainless.extraction.imperative.ImperativeCleanup.stainless$extraction$oo$CachingPhase$$super$extractSymbols(ImperativeCleanup.scala:17)
	at stainless.extraction.oo.CachingPhase.extractSymbols(ExtractionPipeline.scala:28)
	at stainless.extraction.oo.CachingPhase.extractSymbols$(ExtractionPipeline.scala:13)
	at stainless.extraction.imperative.ImperativeCleanup.extractSymbols(ImperativeCleanup.scala:17)
	at stainless.extraction.imperative.ImperativeCleanup.extractSymbols(ImperativeCleanup.scala:17)
	at stainless.extraction.CachingPhase.extract(ExtractionPipeline.scala:97)
	at stainless.extraction.CachingPhase.extract$(ExtractionPipeline.scala:82)
	at stainless.extraction.imperative.ImperativeCleanup.extract(ImperativeCleanup.scala:17)
	at stainless.extraction.utils.DebugPipeline.extract$$anonfun$2$$anonfun$1(DebugPipeline.scala:136)
	at scala.util.Try$.apply(Try.scala:210)
	at inox.utils.TimerStorage.runAndGetTime(Timer.scala:93)
	at inox.utils.TimerStorage.run(Timer.scala:88)
	at stainless.extraction.utils.DebugPipeline.extract$$anonfun$1(DebugPipeline.scala:136)
	at stainless.extraction.utils.DebugSymbols.debug(DebugPipeline.scala:64)
	at stainless.extraction.utils.DebugSymbols.debug$(DebugPipeline.scala:29)
	at stainless.extraction.utils.DebugPipeline.debug(DebugPipeline.scala:124)
	at stainless.extraction.utils.DebugPipeline.extract(DebugPipeline.scala:137)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.extraction.ExtractionPipeline$AndThenImpl$1.extract(ExtractionPipeline.scala:30)
	at stainless.ComponentRun.extract(Component.scala:87)
	at stainless.ComponentRun.extract$(Component.scala:47)
	at stainless.verification.VerificationRun.extract(VerificationComponent.scala:53)
	at stainless.ComponentRun.apply(Component.scala:97)
	at stainless.ComponentRun.apply$(Component.scala:47)
	at stainless.verification.VerificationRun.apply(VerificationComponent.scala:53)
	at stainless.frontend.BatchedCallBack.$anonfun$3(BatchedCallBack.scala:109)
	at scala.collection.immutable.List.map(List.scala:246)
	at scala.collection.immutable.List.map(List.scala:79)
	at stainless.frontend.BatchedCallBack.endExtractions(BatchedCallBack.scala:110)
	at stainless.frontend.ThreadedFrontend$$anon$1.run(ThreadedFrontend.scala:34)
	at java.lang.Thread.run(Thread.java:748)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant