Crash: "Sorts Int and Bool are incompatible" when a JDK method's result is passed to a parameter refined in an external spec

オープン
#451 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java

調査の方向性

Start by reproducing the crash with the provided SocketRefinements.java and Client.java example, then compare it with the in-source refinement case that reports a normal refinement error. Trace how results from unspecified JDK methods and externally refined parameters are translated into verifier sorts. Done means the example reports a refinement error or verifies, without the internal sort error; the literal-port case should continue to verify.

索引モデルが issue の本文から書いたものです。

説明

Impact: passing an int returned by an unspecified JDK method to a parameter refined in an external spec crashes the verifier with an internal sort error. The expected outcome is a refinement error, or an accept. This is the everyday way to connect a socket in tests and tools: new Socket(host, server.getLocalPort()).

Minimal reproducer (an external spec and a client, in one directory)

// SocketRefinements.java
@ExternalRefinementsFor("java.net.Socket")
public interface SocketRefinements {
    void Socket(InetAddress address, @Refinement("_ >= 0 && _ <= 65535") int port);
}

// Client.java
public class Client {
    public static void main(String[] args) throws Exception {
        ServerSocket server = new ServerSocket(0);
        Socket s = new Socket(InetAddress.getLoopbackAddress(), server.getLocalPort());
        server.close();
    }
}

Expected: a refinement error, because server.getLocalPort() can't be proved in range. The same shape in-source gives one: port³ == port¹ is not a subtype of port³ >= 0 && port³ <= 65535.

Actual (main @ f7f366c, and 1a506fe):

Error: Sorts Int and Bool are incompatible

With a literal port (8080) the program verifies.

Real-world scenario. I found this while scoring java.net.Socket specs on JVM-checked probes. Every probe that connects to a local test server (new ServerSocket(0), then new Socket(loopback, server.getLocalPort())) crashes the verifier. That happens both with co-specification's generated spec and with the specs-v2 Socket spec, which refines ports the same way (Port(int x) { x >= 0 && x <= 65535 }).

主要言語
Java
スター
71
フォーク
37
平均マージ
1日 19時間
マージ済み PR(30日)
57

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

liquid-java/liquidjava のほかの issue

liquid-java/liquidjava の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。