JetBrains / lincheck

Framework for testing concurrent data structures
Mozilla Public License 2.0
545 stars 31 forks source link

NullPointerException: Parameter specified as non-null is null: #266

Closed ben-manes closed 4 months ago

ben-manes commented 5 months ago
Gradle suite > Gradle test > com.github.benmanes.caffeine.lincheck.CaffeineLincheckTest$BoundedLincheckTest > modelCheckingTest FAILED
    java.lang.ExceptionInInitializerError
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.<init>(BoundedLocalCache.java:270)
        at com.github.benmanes.caffeine.cache.SS.<init>(Unknown Source)
        at com.github.benmanes.caffeine.cache.SSMS.<init>(Unknown Source)
        at com.github.benmanes.caffeine.cache.SSMSW.<init>(Unknown Source)
        at com.github.benmanes.caffeine.cache.LocalCacheFactory.newBoundedLocalCache(LocalCacheFactory.java:48)
        at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.<init>(BoundedLocalCache.java:3953)
        at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.<init>(BoundedLocalCache.java:4451)
        at com.github.benmanes.caffeine.cache.Caffeine.build(Caffeine.java:1073)
        at com.github.benmanes.caffeine.lincheck.AbstractLincheckCacheTest.<init>(AbstractLincheckCacheTest.java:47)
        at com.github.benmanes.caffeine.lincheck.CaffeineLincheckTest$BoundedLincheckTest.<init>(CaffeineLincheckTest.java:40)

        Caused by:
        java.lang.NullPointerException: Parameter specified as non-null is null: method org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.identityHashCodeDeterministic$lincheck, parameter obj
            at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.identityHashCodeDeterministic$lincheck(ManagedStrategy.kt)
            at com.github.benmanes.caffeine.cache.References$WeakKeyReference.<init>(References.java:188)
            at com.github.benmanes.caffeine.cache.NodeFactory$RetiredWeakKey.<init>(NodeFactory.java:160)
            at com.github.benmanes.caffeine.cache.NodeFactory.<clinit>(NodeFactory.java:38)
            ... 10 more

This is when the build upgrades from 2.18.1 to 2.24. The hash of null is well defined (zero by System.identityHashCode` so I think this method should be loosened. The instrumented constructors all handle this null parameters properly.

ben-manes commented 5 months ago

When trying to work around this a different NPE appears,

java.lang.NullPointerException: it.first must not be null
    at org.jetbrains.kotlinx.lincheck.runner.ParallelThreadsRunner.run(ParallelThreadsRunner.kt:286)
    at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.runInvocation(ManagedStrategy.kt:243)
    at org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.ModelCheckingStrategy.runImpl(ModelCheckingStrategy.kt:62)
    at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.run(ManagedStrategy.kt:130)
    at org.jetbrains.kotlinx.lincheck.LinChecker.run(LinChecker.kt:126)
    at org.jetbrains.kotlinx.lincheck.LinChecker.checkImpl(LinChecker.kt:80)
    at org.jetbrains.kotlinx.lincheck.LinChecker.checkImpl$lincheck(LinChecker.kt:52)
    at org.jetbrains.kotlinx.lincheck.LinChecker.check(LinChecker.kt:42)