Skip to content

Abla 0.2.77

Choose a tag to compare

@AndreBaltazar8 AndreBaltazar8 released this 26 Nov 08:35
· 506 commits to master since this release

v0.2.75 and v0.2.76 were tagged but never published (their Windows ARM64
builds failed), so these notes cover everything since v0.2.74.

Behaviour changes and migration (read first)

  • GPU kernels: the CUDA host types are sealed and launches are checked
    (high; fixes the known issue of v0.2.72 to v0.2.74).
    Code that is not
    trusted could make abla/kernel reach memory it does not own:

    • CudaKernelDevice and CudaKernelMemory could be constructed
      directly, with any address, context or module. Their constructors are
      now native.trust errors outside trusted code; get them from the
      device and allocate as before.
    • CudaKernelDevice.launch passed its arguments to the driver unchecked.
      It now refuses a launch whose arguments don't match the kernel's
      parameters (number and kind: an integer or a byte buffer where an f32
      buffer goes), or that passes a buffer of memory already freed or of
      another device. The compiler records each kernel's parameters in its
      PTX for this; rebuild kernels with this release.
    • kernelSharedF32 and kernelSharedU32 (since v0.2.73) refuse a
      count above 1,048,576 with a panic. Before, a huge count wrapped the
      allocation size on the CPU backend.
    • The kernel build's scratch directory is created with a random name,
      exclusively and readable only by you, instead of a name another user
      of a shared /tmp could create first (low).

    Every bounds check inside a kernel held: a differential of edge indices
    between the CPU and an RTX 4090 found no difference. (6fb4d39, #1139
    area 13)

  • ed25519Verify refuses public keys of small order (low). A public key
    of order 1, 2, 4 or 8, such as the identity point, accepted signatures
    that anyone could make for any message without a secret key. No signer
    holds such a key, so verification now returns false for it. RFC 8032
    doesn't require this, and Wycheproof accepts either answer. No real key is
    affected. (b9d78b5, #1139 area 5)

Fixes

  • Reading a very long number is no longer quadratic (medium; fixes the
    known issue of v0.2.14 to v0.2.74).
    parseFloat, JSON's asF64 and
    readNumber, and the static libc's strtod/strtof took time quadratic
    in the number's digits. One request carrying a JSON number of about a
    megabyte, which fits the default limits, could keep a server busy for
    about two minutes. f64Parse now reads at most 800 significant digits,
    plus whether any later digit is non-zero, and still rounds exactly. A
    million-digit number reads in about 6 ms. (7c59b85)
  • Static libc strtod and strtof read hex floats (0x1p3) and
    nan(...), and set ERANGE on overflow and underflow, as glibc does.
    Before, a hex float read as 0. A differential test against glibc runs
    20,000 generated inputs per seed. (307694e, 7c59b85)
  • $sql: a wildcard takes no alias. The checker accepted SELECT * x,
    which PostgreSQL refuses. (e18864e)
  • Imported main: a program whose import chain has three modules, each
    with a main, no longer fails with symbol.duplicate:main. This had been
    broken since v0.2.60. (613a9e0)
  • Windows toolchain: moving the unpacked toolchain retries, a bounded
    number of times, when a file in it is still held open (a sharing
    violation or "access denied"), without leaving a partial copy behind.
    (4de4837, 3220257, 88a46fd, aecb4a1)
  • await on a task or thread written in place (high; fixes the known
    issue of v0.2.61 to v0.2.74).
    await task { ... } and
    await thread { ... }, with the task or thread written directly after
    await, did not keep it alive while it ran, so a garbage collection
    inside its body freed it and the program crashed (or could use freed
    memory). A task or thread bound to a val first was not affected. Such
    values are now kept alive across the await, and across a generator's
    next, close and drop. (52c90aa, e424664, #1139 area 7)
  • C callbacks into Abla (medium): a value computed in an expression
    and still needed after a C call that calls back into Abla (a comparator
    passed to bsearch or qsort through nativeFunctionAddress) could be
    freed by a collection inside the callback. Such a C call now keeps those
    values alive. It needs a project's own extern declaration; a blocking
    call to the standard library was never affected. (e6792f6, 8620425,
    #1279)
  • Release files (low): the signed SHA256SUMS and the SBOM no longer
    list the signing script's own scratch files (v0.2.73's listed an empty
    SHA256SUMS.tmp), and verify-release on a whole directory refuses a
    listed file that is missing instead of skipping it. (38023f5)
  • Reproducible releases: the dynamic Linux compiler is byte-identical
    whichever build shell made it (the shell's own library directory no longer
    ends up in its run path); the SBOM lists the OpenSSL of the build environment
    (not a library the compiler needs), and the trust roots (read from the host, not
    shipped); and the release check confirms that the static compiler was
    built from the published dynamic asset. docs/reproducibility.md says what
    is reproduced bit for bit (the dynamic asset) and what is checked by its
    fixpoint instead (the static asset). (1d9cd44, a7f82a9, d627ef5,
    1e61393, 8b0855c)

Improvements

  • Browser playground: the compiler's memory collector does less work per
    allocation and grows in 24 MiB steps. In Chrome, the regex benchmark went
    from 12.3 s to 8.5 s, n-body from 3.4 s to 2.7 s, and spectral-norm from
    3.4 s to 2.7 s. Native compile speed is unchanged. (a2d627c, bbb7fec)
  • Editor: edits inside a leading line comment of a checked body are
    re-checked incrementally. On abla-one, the first edit's answer went from
    1.18 s to 0.19 s. (1b3d447, 6dd4c28)
  • Editor suggestions: analysis offers two new edits in your own code:
    an early return for a nullable value, and a loop that fills a fresh array
    rewritten as array.mapped. (0b1ce1b)
  • Duplicate exports: a second @export or @exportLocal of a name now
    points at itself and notes which function already exports that name, and
    where. (12ae17b)
  • C calls: a non-blocking C call with a plain number result no longer
    stops at a memory-pressure check. Tight loops of such calls run fewer
    instructions; two abla-embedded host fixtures went from 403 to 78 ms and
    from 161 to 81 ms. A loop that makes only such calls keeps one check per
    pass, so another thread's collection can still pause it. (b6f548d,
    741a3e3)
  • GPU kernels (experimental): KernelU32Buffer.atomicAdd (one
    indivisible add that gives the old value, bounds-checked like a load) and
    kernelFence(), so the last group to finish can combine every group's
    results in one kernel; and kernelSubgroupShuffleXor and
    kernelSubgroupShuffleXorInt (CUDA's __shfl_xor_sync). (51f2604,
    9cfd346)

Known issue

  • 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.
  • A dependency's compile-time transform can generate an extension function, an extension field or an extend for a type of another package without transform.program, and such generated code runs with your project's grants when your own compile-time code uses it. Until v0.2.78, don't authorize compile-time capabilities for your own project when you build with dependencies you don't trust. Fixed in v0.2.78.
  • 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.
  • Safe code can make the GPU kernel runtime (abla/kernel, abla/kernel/cuda) read or write memory it doesn't own. Until v0.2.79, don't run kernel code from dependencies you don't trust, open one CUDA device at a time, and don't upload to or download into a buffer you have closed. 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.

Docs

  • The dynamic Linux compiler stays an opt-in asset beside the static
    default, and the docs say why: it is the only Linux compiler that can run
    compile-time nativeLibraries (dlopen). The TLS docs say the standard
    library's TLS is pure Abla, and the OpenSSL-based hosted TLS is only for
    programs that import it. (edb1fbe, 0566deb)
  • docs/language.md says what makes a small GPU kernel fast (loads in flight
    before their first use, branch-free helpers, fast paths chosen from
    parameters rather than loaded values, 32-bit counters), from comparisons
    of abla-grad's kernels with CUDA C. (5caddcd)

Tests

  • TLS (#1144 round 6): our client against a hostile server's PSK answers, a
    forged ticket lifetime, and KeyUpdate and NewSessionTicket floods.
    Randomness after fork, ECDSA signing without the random source, and
    X25519 small-order shares in TLS (#1139 area 5). HTTP differential fuzzing
    rules against llhttp and Go.

Bootstrap convergence

Two fresh Linux builders bootstrapped the source of v0.2.77 (780cc519c789b2c99a60b2867e3aa6481b3af91f) from different seeds and reached the same compiler:

  • route A: v0.2.74 (ablac-x86_64-linux sha256 03337bf89f919b8506497894ecf20723a8e04e9f3a4f86a42a9e3d9ac7bc7471) -> stage 1, 2, 3
  • route B: v0.2.73 (sha256 8a67ba0cf4e28af968e1b36899c87db2b77c48249674b017cfa7cda620dd23e2) -> the sources of v0.2.74 (e69fba5065dcf67b2c2758cc5ae8137c807898cb), twice -> stage 1, 2, 3
  • canonical IR (raw, non-debug, pre-prune --emit-llvm src/orc_main.ab at /build/source): sha256 3d6e0573983d9afad338da5f25a607a7f7bfa0665afe7c7091ef276a30b1abdd
  • stage 2 executable 8d3a72daa473bb6b0a93a6b5a14eec0c0d4f61f515daeee21437c73b0509ce8f, object ff8d56feb158c8bc641b695c2732d7f56c9759f604de3e5fee4c8681bd5788a4
  • toolchain: environment b29f16979086b7cd1ad963443ccfcb9fe9ce3696728ba932a1a93c106ea7e426, closure b1872f918c677d4b376f11826949774047bafeac6c208592b89a05f2dc4640aa
  • run: https://github.com/AndreBaltazar8/ablac/actions/runs/45754457699

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).