Skip to content

std and contrib call other modules' raw layer (97 calls in 49 files) instead of their public API #3107

Closed

Description

@nicolas-maman

std and contrib call other modules' raw layer instead of their public API (owner report). A std module binds C through *_raw externs and builds its public functions on them; nothing keeps another module from calling the raw layer directly, so 49 files make 97 such calls, outside the module that declares them:

Raw functions Calls Where Public API to use
list_get_raw, list_add_raw, map_put_raw, map_get_raw, map_keys_*_raw about 55 clapae, asn1, tls13_cert/client/server, http1, language, message, sandbox, schema, tar, zip, http lb, liquid, vkgen, xml_expat, tinyweb, tests list.add, list.get, map.put, map.get, map.keys
intarr_*_raw, longarr_new_raw 30 bignum and about twenty cryptography modules, liquid int[] / long[] slices (make([]int, n)), which std.intarr/longarr predate
http_*_raw, tcp_*_raw, file_*_raw, dir_list_raw about 15 tls13_*, http lb, tinyweb tests http.get/post/..., tcp.connect/receive, fs.read, fs.list

Calling the raw layer skips what the public function adds: error results (T!), ownership (@aether/@retain on the stores), bounds checks (slices), and the documented contract, and it ties the caller to a C binding the module is free to change.

Fix:

  • Every cross-module raw call moves to the module's public API (slices for the int and long buffers), each module verified by its own tests and test vectors, the cryptography modules' throughput measured before and after.
  • A check in Aether, run in CI, that no std or contrib file calls a *_raw extern declared in another module, so it does not come back.
  • Where a public function a caller needs does not exist, it is added (no new raw call).

Found on #3101.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstdlib

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions