Xo 0.50 release notes
Downloads: Xo 0.50.1 on GitHub,
with archives for macOS (Apple silicon and Intel, signed and
notarized), Linux (arm64 and x86-64), and Windows (x86-64, Authenticode
signed), and a SHA256SUMS file.
Xo 0.50.1, the first public 0.50 release (0.50.0 was an internal seed), fixes two security issues (a JSON request that could crash a server using json.decode_go, and TLS peer keys over 8192 bits), fixes two crashes (a native arm64 program whose large struct result was overwritten before it was read, and a rare one of programs whose tasks are canceled), adds RSA encryption, reads and writes times of any year from 0001 to 9999 (time.Civil with parse_civil and format, and in std/yaml, std/mail and std/asn1), lets an interface method take var self, writes protobuf messages up to about a third faster, and fixes faults in LLVM builds on linux/amd64. The playground’s REPL now needs at most 37 MB of memory.
Upgrade advice: if you build native programs on arm64 (Apple silicon, Graviton) with 0.49.0 or 0.49.1, upgrade; a call returning a large struct could crash them (see Fixes).
Two changes can stop a program that compiled with 0.49.1 from compiling: std/asn1 gains a Value.WideTime variant, so an exhaustive match on asn1.Value needs that arm, and a var method no longer implements an interface method that takes a plain self (see Breaking changes).
Security
- std/tls (native backends): a TLS peer certificate with an RSA key over 8192 bits is refused, with Go’s text (
tls: server sent certificate containing RSA key larger than 8192 bits), before any signature is verified. Huge keys made the peer’s handshake cost CPU time (Go’s CVE-2023-29409, GO-2023-1987). The Go backend already refused them. - std/json (native and LLVM backends):
json.decode_gono longer faults when a type error sits under a non-ASCII object key ({"é": "x"}decoded intoMap[Str, Int]); it returns Go’s error,json: cannot unmarshal string into Go value of type int. One such request could stop a server that decodes peer JSON withdecode_go. Found by the decision 0616 review of std/json.
Highlights
- RSA encryption (std/crypto, decision 0618):
crypto.encrypt_oaepandcrypto.decrypt_oaep(RSA-OAEP, Go’sEncryptOAEPandDecryptOAEP) are the recommended scheme;encrypt_pkcs1v15anddecrypt_pkcs1v15are legacy, for systems that require them. Decryption checks padding in constant time and reports every failure as the onecrypto/rsa: decryption error. - Times of any year (decision 0614):
time.parse_civilandLayout.parse_civilread whatparsereads, for years 0001 to 9999 (Go’s zero Time,9999-12-31, BigQuery TIMESTAMP), into atime.Civil;Civil.format,Layout.format_civil,Civil.unixandCivil.to_timewrite and compare them.Timekeeps its 1677 to 2262 range. Atime.Civilfield in std/yaml reads and writes any year (four digit years, as yaml.v3),mail.parse_date_civilreads RFC 5322 dates of any year, and std/asn1 parses UTCTime and GeneralizedTime of any year (see Breaking changes). var selfin interfaces (decision 0613): an interface method may takevar self, and a generic bound’s call of one (fn fill[T: Loader](var t: T) { t.load(5) }) updates its receiver on every backend (native, LLVM, Go). Through an interface value (var l: Loader = Box{}; l.load(3)) it works on the Go backend, updating the value in its place (a copy made before the call keeps the old value); the native backends still report XO1201 for it.- Faster protobuf (std/protobuf, std/prelude): varints and fixed width values are written as one word, derive Proto writes each field’s key with its value (new
put_key_varint,put_key_fixed32,put_key_bytes), andBytesBuilder.write_le,write_byteandStrBuilderpushes store in place. Each step’sxo bench --abon linux/arm64 against the main before it: bench/perf/protobuf marshal 0.856 (varint words), 0.847 (keys with values), 0.827 (write_le); the JSON token writer 0.918 (write_byte). Output bytes are unchanged. - The playground’s REPL (xolang.dev/repl/, decision 0583): its compiler peaks at 37 MB over a 30-entry session, was 49 in 0.49.1, and later entries run a little faster.
Breaking changes
- std/asn1 (decision 0614): a UTCTime or GeneralizedTime outside 1678 to 2261 parses as the new
Value.WideTime(c: time.Civil, generalized: Bool)(its wall clock and offset), where it wasasn1: time out of range;derwrites it back in UTC, as Go’s Marshal. Migration: add aValue.WideTime(c, g)arm to exhaustive matches onasn1.Value. - Interfaces (decision 0613): a type’s
varmethod no longer implements an interface method that takes a plainself(new error XO0439). The checker used to accept it, but a call through the interface would have lost the update, and every native build reported XO1201. Migration: if callers through the interface may change the value, declare the interface methodfn name(var self, ...)and give generic callers avarreceiver (fn fill[T: Loader](var t: T)); if the method only reads, make it a plain methodfn (x: T) name(...).
Behavior changes
- wasm,
BytesBuilder.write_le: a width outside 0 to 8 is the fault the native backends raise (exit 70, the same text), where it trapped (“unreachable”, exit 134).
Not in this release
- Borrowed struct projections (decision 0612), listed in the changelog, are off in 0.50.1: a native build of the Azure SDK’s pagers crashed (SIGSEGV) with them on. They return when that is fixed.
Fixes
- arm64 native builds: a call returning a large struct (a result wider than the return registers) could have its result overwritten by a value’s cleanup call before the caller read it, a segmentation fault (since 0.49.0; 0.48.2 and earlier are not affected). Found through a native build of the Azure SDK’s pagers.
- Canceled tasks (native backends and LLVM): a task canceled while it waited for another task to build a constant (a sibling failed while the constant’s first read was in progress) now unwinds; it read past an empty list, and the program crashed with SIGSEGV about 1 run in 30 under load. Present since at least 0.48.2.
--backend=llvmon linux/amd64 and freebsd/amd64: a fault (an overflow, a failed contract, an unhandled error) crashed the program with SIGSEGV instead of reporting the fault and exiting 70. Andxo dump(and SIGQUIT) of an LLVM build named the runtime’s frame (poll.xo:1187) as a blocked task’s site instead of the program’s line.- Closures (native backends): a closure with no written result whose body ends in an
ifor amatch(fn(d: Int) { if d > 0 { d } else { 0 } }) builds; it was XO1201 “convertingResult[Int, _]toInt” (the Go backend ran it). - Diagnostics: an XO1201 found while lowering a closure body names the place (the returned expression, else the closure literal or the function); it had no file or line.
- Checker: a type alias reached again through a struct or enum (
type Schema = List[Field]withstruct Field { schema: Schema }) is no longer a false XO0407 “type alias refers to itself”. - std/yaml: a
time.Civilfield outside 1677 to 2262 failed to parse, and a year below 1000 was written without its leading zeros (1-01-01T00:00:00Z).