Skip to content

Abla 0.2.70

Choose a tag to compare

@AndreBaltazar8 AndreBaltazar8 released this 24 Nov 21:03
· 672 commits to master since this release

Behaviour changes and migration (read first)

  • Dependencies need a grant to define trusted or extern code. A
    dependency that defines a trusted function or declares an extern
    function now fails the build with E_PACKAGE_TRUSTED_DENIED unless your
    root abla.toml names it and abla.lock pins it by digest, for example
    for abla-blockchain:

    [dependencyCompileCapabilities]
    abla-blockchain = ["trusted.native"]

    The error names the package, the function and its file and line, and
    prints the line to add. One line covers a package's sub-paths; a
    dependency of a dependency needs its own line. Your own project and the
    standard library are not affected. The same line does not let a
    dependency run native code at compile time unless your project allows
    that for itself. Before, any dependency could define trusted code and do
    raw memory operations whatever the root allowed. Of the published
    packages, only abla-blockchain (its wallet) needs the line; abla-mvc,
    abla-nats and abla-redis no longer define trusted code, so run
    ablac package update if your lock pins an older version. (9086ec5,
    decision #122)

  • The TLS client checks OCSP staples by default. The standard library's
    TLS clients (tlsConnect and its variants, the HTTPS clients, the
    WebSocket TLS client) now ask the server for a stapled OCSP response and
    check it when one comes: a revoked certificate fails with
    certificate_revoked; a staple for another certificate, from the wrong
    signer, out of date or valid for more than 10 days fails with
    bad_certificate_status_response; a must-staple certificate without a
    staple fails with bad_certificate. A server that sends no staple
    connects as before. tlsLastError() reports these as "TLS failed at
    certificate_verification". Set revocation = 0 in TlsClientConfig to
    opt out. A configuration you build with your own verifier is unchanged,
    and the OpenSSL-based hosted client has no revocation check. A handshake
    with a staple costs about 0.6 ms more. (5f116ba, decision #120)

  • Android: libabla_app.so imports nothing from bionic. An arm64
    Android library no longer names libc.so: the five pthread functions it
    used (thread-local keys, and thread start and join) are now handed to it
    by its host through a table, abla_android_host_install(table), declared
    in the generated abla-app.h. The generated libabla_jni.so installs the
    table in its JNI_OnLoad, so an app built the standard way needs no
    change. A host that loads libabla_app.so through its own bridge must
    install the table before calling an export; without it, the first call
    that needs one of those functions prints why and ends the process with
    status 70. abla-mobile already does this. (b3f11cf, decision #121)

  • WebSocketServerRead is renamed SocketReceiveResult and moves to
    abla/sys/linux/net, next to the new linuxTcpReceiveDescriptor: one
    bounded, non-blocking read from a descriptor (status is the count, 0 at
    end of file or a negative errno; the descriptor stays open).
    webSocketServerReceive is built on it. (e10ba6f)

Fixes

  • Windows sockets (high; closes the known issue of v0.2.67 to v0.2.69):
    in programs built for Windows, a socket read that failed (a connection
    reset by the peer, a read that would block, or a read timeout) was taken
    as a read of 4 GiB. Depending on the reader, the program crashed or read
    memory past its buffer, and a remote peer could cause either. A failed
    Winsock call is now a negative error, as on Linux. SO_RCVTIMEO and
    SO_SNDTIMEO also waited milliseconds where seconds were asked for; they
    now wait as long as asked, and a timed-out send or receive is EAGAIN, as
    on Linux. Rebuild Windows programs that use the network. (a2768a7)
  • Windows process start and paths (critical and high; closes the known
    issue of v0.2.67 to v0.2.69):
    from a review of the Windows runtime.
    • Starting a program by a bare name (git, lld-link) let Windows look
      in the current directory, so building an untrusted checkout with the
      Windows compiler, or any Windows program that starts another by name,
      could run a file of that name from that directory. A bare name is now
      looked up beside the running program and then on PATH, never in the
      current directory.
    • Starting a .bat or .cmd file with an argument containing ", %,
      ^, &, |, <, >, (, ), ! or a line break could run other
      commands, because cmd.exe reads the command line again. Such
      arguments are now refused with EINVAL.
    • A directory path longer than about 2,040 characters, or a process
      argument larger than the command-line buffer, wrote past a buffer. The
      argument is now refused with E2BIG, and long paths work.
    • Also: two threads closing one descriptor no longer close a handle
      twice, a link's target is read within the bytes Windows returned, a
      negative descriptor in poll is ignored as on Linux, and a very long
      socket timeout no longer overflows.
      Rebuild Windows programs, and update the Windows compiler. (c2315ed)
  • Windows build cache (closes the known issue of v0.2.68 and v0.2.69):
    ablac build with the cache on no longer stops with "unsupported Linux
    system call 326"; you can drop --no-cache. A new check fails the build
    of the compiler if any system call the compiler or the standard library
    makes on Windows is neither translated nor listed with a reason.
    (fd240f3, c217171, 738126a)
  • Compile-time paths on Windows (#1201): like Linux and macOS since
    v0.2.69, a compile-time path is opened directory by directory from the
    project, and a junction or symbolic link swapped in between the check and
    the use is refused, so it can no longer lead a compile-time read or write
    out of the project. (2bd2092)
  • Windows files and memory: FileLock works (it ended the program with
    status 70: flock is now LockFileEx), and so do chmod, hard links,
    utimes and reads at an offset (f522fda, 49a67b0). mprotect on
    memory reserved with no access (the frozen heap's window) now commits the
    pages, so they become usable instead of failing on the first store
    (de1a678). homePath falls back to USERPROFILE when HOME is unset
    (fccb746), and process metrics (working set, commit charge,
    descriptors, creation time) are available as on Linux (bc6d952).
  • Windows crash reports: a crash inside memmove, memcpy or memset
    (for example a copy past the end of a buffer) now names the calling
    function in a --backtrace stack, instead of a meaningless address.
    (81991fa)
  • WebSocket TLS client: TlsWebSocketConnection.readFrame can now be
    given a deadline for a whole frame (readFrame(maximumPayload, timeoutMilliseconds)), and setReadTimeout sets the limit for reads that
    name none. A read that runs out reports timedOut, keeps the connection
    open and keeps the bytes it read, so the same call can be repeated. The
    upgrade response must arrive within the connection timeout as a whole, not
    per read. The default is unchanged: no limit. (cf48176)
  • Regions: a method call's region summary is now found for receivers
    built by a unique constructor or returned by a call with a declared type,
    and for typed module-level values. Before, these fell back to a
    conservative answer. (c3782c5, cdb7a2c)
  • Playground: a browser run explains a capability the page denies and a
    companion file it is missing, and an i64 result of main becomes the
    exit status. (f1a8018, 8e0f296, 0f0a6a9)

Performance

  • Portable compile-time code with maps: compile-time code that uses the
    built-in Map with scalar keys and values now runs in the portable
    WebAssembly slice instead of falling back, with Map types checked at the
    call; a WASI catalog build is 8.5× faster. (d31a5fb)
  • Compiler scaling: very wide when arms over literals, long chains of
    member calls, very wide sums and functions with many regions no longer
    slow compilation down out of proportion. Wide literal dispatch uses LLVM
    switch lookups, literal keys and large block tables are indexed, type
    queries are reused along a receiver chain, and wide additions are
    reassociated before machine lowering. (3237a4a, 9372d95, c533b53,
    d869ed1, 8b4a5b7)

Docs

  • JSON: how to replace hand-built JSON with literals, with a diagnostic
    that points there (2722372), and the null fallback jsonParse
    already returns (8b2a7e0). The tour shows nullable early returns
    (79e5cd4); arrays document the checked first-element idiom
    (a9e428f); the compiler API shows how a build action reports a failure
    with a compile-time panic (7284308).

Known issue

  • await task { ... } or await thread { ... }, with the task or thread written directly after await, doesn't keep it alive while it runs: a garbage collection inside its body can free it, and the program crashes or uses freed memory. Until v0.2.77, bind the task or thread to a val first (val t = task { ... }; await t). Fixed in v0.2.77.
  • Reading a very long number as a floating-point value (parseFloat, JSON's asF64 or readNumber, strtod) takes time quadratic in its digits, so one request carrying a JSON number of about a megabyte can keep a server busy for minutes. Until v0.2.77, reject or truncate numbers longer than a few hundred digits before converting them, or keep request bodies small. Fixed in v0.2.77.
  • A dependency's compile-time transform, or its custom $ syntax handler, can run compile-time code with your project's own compile-time grants (process, environment, file writes, network, native code), not the dependency's. Until v0.2.74, don't authorize those capabilities for your own project when you build with dependencies you don't trust. Fixed in v0.2.74, except for the case below.
  • A compile-time # site that a dependency's custom $ syntax handler builds into your file runs with your project's own compile-time grants (process, environment, file writes, network, native code), not the dependency's. Until v0.2.78, don't authorize those capabilities in a file that uses $ syntax from a dependency you don't trust. Fixed in v0.2.78.
  • ablac package update can run a dependency's compile-time import-provider code with your project's own compile-time grants (process, file writes, network), before the dependency is locked. Until v0.2.74, don't authorize those capabilities for your own project while you update dependencies you don't trust. Fixed in v0.2.74.
  • On Linux and macOS, building an untrusted project can run a program from
    that project when a tool the compiler starts (a linker, a C compiler or an
    LLVM tool) is not on PATH, or when PATH has an empty, . or relative
    entry. Until v0.2.71, keep every PATH entry absolute and the tools
    installed when you build code you do not trust. (Windows is fixed in this
    release; see Fixes.) Fixed in v0.2.71.
  • A module brought in with import contract whose declarations include
    trusted or extern functions fails to build with
    E_PACKAGE_TRUSTED_DENIED, even in your own project. A
    [dependencyCompileCapabilities] line does not help, because the
    contract's copy of the module belongs to no package. Build such projects
    with v0.2.69 until v0.2.71, which fixes it.
  • Android libraries built with the release (static) Linux compiler are generated as if for plain Linux on arm64, not for Android. They use native ELF thread-local storage instead of emulated TLS, so on Android 7 to 9 (API levels below 29) loading such a library can fail. They also use register x18, which Android reserves (on Android 9 and later it holds the shadow call stack), so a library may crash on any Android version. To work around it, set ABLA_CODEGEN_INPROCESS=0 and have LLVM's opt and llc on PATH (or set ABLA_LLVM_TOOLS): the compiler then runs them instead of its own code generation, and the library is built for Android. This affects v0.2.66 and later. Fixed in v0.2.71.
  • On Windows on ARM64 (aarch64-windows) only, a program that uses AES-GCM ends on its first call with "fatal signal: Windows exception 0xc000001d". That includes every TLS client and server, and anything using abla/crypto/aes: the CPU feature check reads a register Windows does not let programs read. There is no workaround in the program. Rebuild with v0.2.72. x86-64 Windows, Linux and macOS are not affected. (Found by the Windows ARM64 CI lane; no user has reported it.) Fixed in v0.2.72.
  • On macOS, adding a new entry to the package cache fails (a freshly
    fetched git dependency, or new content from a content provider): the
    compiler runs chmod -R go-w -- <dir> on it, and the system's BSD
    chmod reads the -- as a file name. Entries already in the cache,
    vendored dependencies whose digest matches and local path imports are not
    affected. Until v0.2.71, put a GNU chmod first on PATH (Homebrew's
    coreutils installs it as gchmod; link it as chmod in a directory
    ahead of /bin). Fixed in v0.2.71.
  • Ordinary code can write fields that the standard library's native buffers and cells rely on (closed of a NativeByteBuffer, NativeI64Cell or NativePointerCell), so safe code can reach memory it doesn't own. Until v0.2.79, don't write those fields outside the standard library, and check that your dependencies don't. Fixed in v0.2.79.
  • A dependency's custom $ syntax handler can have code of its own run at compile time with the grants of your file that uses the syntax (process, environment, file writes, network, native code). Until v0.2.79, don't authorize those capabilities in a file that uses $ syntax from a dependency you don't trust. Fixed in v0.2.79.
  • A dependency's prepared copy in .abla/packages/ is trusted by its marker files without checking its contents against abla.lock in single-file builds, and in project builds that also have a vendored copy, so a changed copy (from a restored CI cache, or committed next to a reviewed lock) is built as is. Until v0.2.79, delete .abla/packages/ before building when it may come from somewhere you don't control (it is fetched again and checked), and don't cache or commit it. Fixed in v0.2.79.
  • The HTTP clients (HttpClient.send, HttpAsyncClient, and the WebSocket TLS client's upgrade request) write the method, path and header values they are given without checking them, so a line break in a value that came from user input can add headers or a second request. Until v0.2.79, percent-encode user input in paths and queries (percentEncode) and refuse CR, LF and other control bytes in header values before passing them to a client. Fixed in v0.2.79.
  • The static Linux compiler's own hardening was weaker than a glibc build's: its stack-protector canary was a fixed value on AArch64, its _FORTIFY_SOURCE buffer checks did nothing, and realpath could overrun its caller's buffer with a very deep working directory plus a long relative path. None of these is reachable alone; each makes a separate overflow bug in LLVM or lld easier to exploit when compiling code you don't trust. On AArch64 its printf family also read arguments from the wrong place, so text that LLVM formats could show stack contents or crash the compiler. Until v0.2.79, on x86-64 Linux the dynamic compiler asset (ablac-dynamic-x86_64-linux, built on glibc) avoids them; elsewhere, build code you don't trust from a shallow directory. Fixed in v0.2.79.

Bootstrap convergence

Two fresh Linux builders bootstrapped the source of v0.2.70 (93841eec824233d18cfa987bd1bb7d430deac016) from different seeds and reached the same compiler:

  • route A: v0.2.69 (ablac-x86_64-linux sha256 eeddb7c09e282df4b9b7c79714dac68d2ebb21f9a4e7e90c1211f110c7be8f61) -> stage 1, 2, 3
  • route B: v0.2.68 (sha256 4f7dee2c7a16826705aa32e7ba5466b599cc1432274190007e4ea582883a3a09) -> the sources of v0.2.69 (150c711dffa00a28993196e4f3d24bc45525878a), twice -> stage 1, 2, 3
  • canonical IR (raw, non-debug, pre-prune --emit-llvm src/orc_main.ab at /build/source): sha256 611ac5536b27c378569b8a30fb000fff917179d04e764e4534044cdec4ad87dd
  • stage 2 executable 7c7a74514a345f425275ec1ea5e094e6e9e8c51170dc5f405a5be8f395b89d26, object 55021130350e25452b466a23a2763bf2d6ef5cdd50605f934ea353e984b76066
  • toolchain: environment d00897b2d6cc51118a9495656126ec6b32b87504a2eb780e173bac4eec54f68b, closure b1872f918c677d4b376f11826949774047bafeac6c208592b89a05f2dc4640aa
  • run: https://github.com/AndreBaltazar8/ablac/actions/runs/45466124461

This is route convergence within one compiler lineage: it is not an independent implementation, and it does not exclude a seed compromise shared by both routes (docs/bootstrap.md).