Skip to content

Code review summary #101

Open
Open

Description

@lrytz

I asked Claude for a code review of this repo.

First, according to claude, this repo is mainly relevant for sbt 1.x

  • sbt 1.13.x uses it for every server and client connection. JNI is the default on Apple Silicon, JNA everywhere else.
  • sbt 2.x uses the JDK's own Unix domain sockets

sbt 2.x still bundles ipcsocket in sbtn for Windows, as the named pipe client for servers older than 2.1.0.

Both sbt 1.x and 2.x use ipcsocket from the 1.x branch; develop never shipped. Fixes need to be backported to 1.x where they apply.


PRs

PR Fix Priority Status
#96 ForwardingSocketChannel ignored ByteBuffer position/limit (crash at end of stream, endless write loop) – (not in 1.x) merged
#97 JNI: socket path longer than the system limit overwrote memory and crashed the JVM; array bounds High merged
#98 Native library loaded from a predictable /tmp directory another local user could control Medium, security merged
#99 Unix socket closed itself at end of stream, so a response after shutdownOutput() was lost Medium, behavior change merged
#100 Closing a Windows named pipe socket leaked the pipe, two event handles and a TCP socket High, behavior change merged
#102 JNA: a timed-out named pipe read kept writing into freed memory and lost data; a pending write could read freed memory Medium (on 1.x only the write part applies) open
#103 Closing sockets and server sockets: wake blocked threads, isBound/isClosed, close() during accept(), Windows close hang High open
later JNI named pipe read/write kept going after errors: hang when the peer closes, read timeout fails concurrent writes Medium needs #102
later JNA reported wrong Windows error codes Low needs #102
later Another program could take over the named pipe's name ("pipe squatting") Medium, security needs #103
later CI: run JNI tests with -Xcheck:jni, fail on warnings from ipcsocket's JNI code – needs the JNI PR

Impact on sbt 1.13.x

Not fixed

  • On Windows, a closed peer surfaces as an IOException from read, not -1. Left alone because callers may depend on it.
  • Low priority: JNI string leaks, a fd leak when bind fails in the UnixDomainServerSocket constructor, no arm64 JNI library on Windows, a missing NULL check on CreateEvent, inefficient readLine/readAll.
  • The bundled native binaries predate the recent C fixes; they need a rebuild before the next release.

Activity

  1. eed3si9n commented on Oct 28, 2026

    @eed3si9n
    Member

    First, according to claude, this repo is mainly relevant for sbt 1.x

    • sbt 1.13.x uses it for every server and client connection. JNI is the default on Apple Silicon, JNA everywhere else.
    • sbt 2.x uses the JDK's own Unix domain sockets

    sbt 2.x still bundles ipcsocket in sbtn for Windows, as the named pipe client for servers older than 2.1.0.

    That's right. Since JDK 17 ships with Unix domain sockets, I've ripped out ipcsocket from sbt's develop branch (sbt 2.1.0) from the most part. Since we build sbtn off of the develop branch, and is backported to 1.13.x and 2.0.x, I've kept named pipe support so new sbtn can continue to talk to old sbt servers.

  2. eed3si9n commented on Oct 29, 2026

    @eed3si9n
    Member

    FYI - ForwardingSocketChannel was an idea I had before sbt 2.x requiring JDK 17, and thought it could multiplex between sockets and SocketChannel. It shipped as 2.0.0-M2, but I couldn't get it to stabilize so the develop branch never shipped. sbt 1.x and 2.x are both using ipcsocket 1.x branch.

  3. lrytz commented on Oct 29, 2026

    @lrytz
    ContributorAuthor

    OK, thanks for the heads-up. I'll do backport PRs to 1.x for the ones that apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions