Repository navigation
fix(errors): errors outside the parse and file builtins name the operation and the reason - #1887
Conversation
Rayforce targeted audit passedThe required Rayforce audit gate passed on the latest run. Workflow run: https://github.com/RayforceDB/rayforce/actions/runs/46081766455 |
4b94bb7 to
9665a6f
Compare
singaraiona
left a comment
There was a problem hiding this comment.
Review of 9665a6f: NEEDS CHANGES
One message regression, from .db.splayed.get's pass-through rule. Everything else checks out:
- every code equals dev in my 72-case differential;
- no memory errors under ASan+UBSan;
- no cost on the success paths.
Finding
- A truncated list column now loses its location (
src/store/col.c, thecolumn file: …messages, met throughsrc/store/splay.c:1991)..db.splayed.getadds its ownsplayed <dir>: column '<name>' failed to loadonly to an error without a message, and passes any message through verbatim.- The column loader's path-level messages (
column "<path>": …) are fine there: the path's tail names the column. - The deserializer's new messages carry no path. A splayed table whose list column is cut short used to answer:
corrupt splayed <dir>/lst/: column 'l' failed to load
and now answers:
corrupt column file: the vector data is truncated (16 bytes needed, 8 left)
The truncation detail is new and good, but the message no longer names the file, column or table. The same happens with a half-truncated list column (… (8 bytes needed, 1 left)), and it applies to everycolumn file: …message reached through a loader that knows the path (list, STR list, table and atom payloads). Parted loads lose it the same way. - Fix: prefix the path at the path-aware entry (
ray_col_load/ray_col_mmapof an extended-format file), as the header checks already do (column "<path>": <inner message>). Alternatively, have splay.c addsplayed <dir>: column '<name>':in front of a message that does not name the path. - Test: a list column truncated in a splayed directory, with the message containing the column's path.
Nit
.log.validate "<missing file>"answers.log.validate: the journal failed (io). That is true, but the path is at hand inray_log_validate_fnand the failing file is the useful part..log.openis similar.
What I checked
Memory safety. I read every formatted argument in the diff: about 80 call sites with arguments, across all six families. The rest are plain literals.
- Symbol names come from
ray_sym_str, the interned string, which lives as long as the process (also after theray_release(comb)in splay.c:1794), and are always printed%.*s. - Builtin names come from
ray_fn_name, the builtin's inline NUL-terminated name, at sites reached only by builtins. - Paths go through
EPATH: the compound-literal buffer lives through the call, andray_err_path_ncannot underflow (keep≥ 5, and the UTF-8 walk stops at NUL). ray_err_code_strnever returns NULL: every entry is filled, and an out-of-range value gives"error".alter's length is read before the release, andnremoveis a local.loadsaves errno straight afterfopen.ray_vm_map_file/_idkeep the failing call's errno acrosscloseand set 0 for an empty file.COL_MAP_REASONis read before anything else that could change errno.- No data is ever passed as a format: every site uses a literal format.
ray_verrorbounds the message at 255 withvsnprintf.
Four extra cases push the formats with 250–400-byte names and paths; three of them are refused earlier with a pre-existing message, so they never reach the new formats.
Sanitizers. Under ASan+UBSan (make test-full-bin, setarch -R) these all pass with no report:
error_messages_named,col_file_messages,eval_branch_cov;- the suites for graph, traverse, col, splay, parted, journal, log, upsert, insert, alter and split (1,218 tests);
- my 76-case differential script.
Codes. I ran 72 failure cases on dev (dbf7f8c) and this head: every code is equal.
- Language: reserved
setandlet, top-level, in a lambda, indoand viaeval;times; the generic null to unary, binary and aggregate builtins. - Query:
upsertandinsertpayload errors; a reservedletinside select, update and by:. - Values:
splitat 257 and 300 cuts;alterat 9, −1 and 3, also on a shared value. - Storage: parted bad names (
a/b,..,.x);.db.splayed.setinto a missing directory and a 200-byte one;.db.splayed.getwith a missing, empty, too-short-for-header, truncated-data, bad-version or directory-in-place column, and truncated SYM, STR and list columns; parted with a bad or missing column;.db.splayed.appendinto a read-only directory and with a schema mismatch;loadof a missing file. - Journal:
.log.roll,.log.sync,.log.snapshot,.log.validate. - Graph:
.graph.buildwithout src, dst or weight; dijkstra, mst, k-shortest, shortest-path, pagerank and random-walk.
Each new message describes the failure that happened, apart from the location loss above. A column that is a directory answers cannot map the file: No such device, which is the OS's true reason, if terse.
The 11 kept empty. All 11 are right:
raisemust stay message-less:ipc.c:924re-renders a message-less error as the raised value.returnis control flow.- The copy helpers keep the original's message.
- The three message-less col.c
nyirefusals are splay.c:1969's retry contract. I checked that no col.cnyigained a message.
The 71 message-less sites left on the head are those 11, #1884's sites (parse.c, csv.c, builtins.c, system.c:664), and computed oom/cancel codes.
Success paths and cost. Apart from comments, the only non-message changes are errno handling on the map-failure paths, the err_to_ray signature, and the alter length read; none touches a success path. No new message sits on a route whose error is discarded by design. The nyi-keyed fallbacks (splay.c's retry, and csr.c's optional files, which only builds a path and strerror on a missing file) are unchanged in effect.
I timed release builds, pinned, interleaved over 4–6 rounds, at 2M rows: a per-row lambda (the select that declines the fast path), a by: with a lambda aggregate, a splayed group, a SYM group and a like filter. All are equal to dev within noise, for example the per-row lambda at 2.27–3.02 ms against dev's 2.62–2.94 ms.
Leaks of state. No message shows a heap address, uninitialised bytes or file contents. Opcodes, counts and lengths are integers.
Merge with #1884 (open, at 4eefd0e). Both can land in either order.
src/core/errpath.his byte-identical in both.- The sources merge cleanly, and the merged system.c, builtins.c, csv.c and parse.c compile with
-Werror. - The only conflict is in
test/test_lang.c: both append tests and entries at the same point, so keep both sides.
Suite and commit. The gcc suite, make -j4 CC=gcc test TEST_ARGS="-j 4": 5933 of 5937 passed, 4 skipped, 0 failed. The commit is one commit, ends Fixes #1886, and has no trailers.
Not covered
- Windows: the static map reason.
- WASM.
- The plan-execution invariant sites (a node without an extension, cyclic plans, >2^31-row joins) and the asof-join and partition-prune NULL-answer sites: I read them but could not reach them from the language.
.emb.hnsw.setfailures.- TSan.
- Running the new tests on a dev build: the differential shows their messages are empty on dev, so their assertions fail there.
9665a6f to
b5f5bc1
Compare
…ation and the reason ## The defect 267 sites in `src` raised an error with an empty `msg`, outside the parse and file builtins that #1884 fixes. A script that caught one had only a code to report: `(set .sys.gc 1)` gave `{code:reserve msg:""}`, a truncated column file `{code:corrupt msg:""}`, `(split s (til 300))` `{code:limit msg:""}`. The count is of every `ray_error(code, NULL)` or `ray_error(code, "")`, including a code computed at run time (`ray_err_code_str(err)`), without `oom` and `cancel`, whose codes say all there is. ## The fix Each of the 256 sites below now names the operation and the reason, in the style #1884 set, with the path or name where there is one. **Codes do not change.** | family | sites | for example, now | |---|---:|---| | language (`src/lang`) | 53 | `set: cannot bind '.sys.gc' (reserve)`; `times: '.sys.gc' is a reserved name`; `neg: the generic null is not an argument; only nil?, type and ser take it`; `call: an argument answered no value` for a callee's C NULL | | plan execution | 59 | `join: a side of more than 2147483647 rows is not supported`; `execute: plan opcode N is not implemented`; `parted execute: the columns disagree on the number of partitions` | | column files and storage | 62 | `column file: the vector data is truncated (N bytes needed, M left)`; `column "<path>": cannot map the file: <reason>`; `.db.splayed.set "<dir>": the save failed (io)`; `.log.roll: the journal failed (io)`; `parted load: table name 'a/b' must be a plain name …` | | graph | 49 | `dijkstra: the graph has no edge properties; build it with a weight column`; `graph.build: the table has no src column 'src'` | | query | 19 | `upsert: the payload has no key column 'k'`; `insert: the row's key 'zz' is not a column of the table`; `let: cannot bind a local (reserve)` | | values | 14 | `split: more than 256 cut positions, got 300`; `alter: index 9 is out of range for length 3`; `as: the target type symbol has no text` | **The plan-execution sites cost nothing on success.** Most there, and the language family's `x ? x : ray_error(...)` fallbacks, are reached only when an invariant fails or a callee answers a C NULL. A message is formatted only on that path. ## The rules from the review of #1884, applied here - **The OS reason is the failing call's own.** - `ray_vm_map_file` (POSIX and WASM, `src/core/platform.c`) keeps the failing call's `errno` across its `close`, and leaves 0 for an empty file. So the column loader's `cannot map the file: <reason>` names the real reason, or `the file is empty`. The Windows map sets no `errno`, so there the message says `the file cannot be mapped`. - `.db.splayed.set` reads no `errno`, because the save's cleanup makes calls after the failing one. It names the code: `the save failed (io)`. - The journal builtins, whose store answers a code only, likewise name the operation and the code (`err_to_ray`). - **A value is read before it is released.** `alter`'s out-of-range message reads the target's length before its release (`tblop.c`, the audit's finding). A target whose value another name shares is in the test. - **Symbol names are printed with their length** (`%.*s`), never as a bare string. - **A long path never pushes out the reason.** Paths go through `ray_err_path` (`src/core/errpath.h`, the same file #1884 adds), which shows a path over 120 bytes by its tail, cut at a character boundary. That covers the column loader's messages, the existing `column %s: …` ones included, the splayed append and the parted load. ## A column's file, table and column, kept (review of #1887) The column reader's new messages say what is wrong but not which file. The table loader used to add the directory and the column only to a message-less error. Now it always does, and adds the reader's reason after them, so nothing dev said is lost: - **A splayed column:** `splayed <dir>: column 'l' failed to load: column file: the vector header is truncated`, where dev said `splayed <dir>: column 'l' failed to load`. - **A parted table:** its partitions load through the same loader, so the message names the partition's directory. - **The `.d` schema:** `splayed <dir>: cannot read .d schema: <reason>`. - **The other loaders that read a column file:** the retired-names list and the file-local symbol codes swallow their errors by design (best effort). The graph's CSR loader answers a code only through the C API. Neither loses a message. - **The journal builtins given a path:** `.log.validate` and `.log.open` name it: `.log.validate "<path>": the journal failed (io)`. Codes are unchanged: a truncated splayed column, `.d` schema and parted column answer `corrupt`, and the two journal cases `io`, as on dev. ## Left empty on purpose (11) - **`raise`** (`ray_raise_fn`): its error carries the raised value, which IPC renders into the reply. - **`return`** (`ray_return_fn`): control flow. - **The error-copying helpers**, which rebuild an error with its own message or with none: `lazy_error_copy`, `ray_retain_owned_refs`, `pq_task_msg_raise`, `ray_enc_snap_error`, and `de_raw_inner` ×2, which keeps a peer's error as it was sent. - **The column loader's three message-less `nyi` refusals** (`col.c`): `splay.c` takes a message-less `nyi` as "retry with the copying loader", a contract. The 28 sites #1884 fixes are not touched here. ## Tests - **`rfl/system/error_messages_named`** (new) asserts code and `msg` for a sample of each family: - `set` (tree-walked and compiled) and `times` on a reserved name, and the generic null as an argument; - `upsert` and `insert` payloads, and `.graph.build` with no `src` column; - `split` over 256 cut positions, and an `alter` index out of range; - `.db.parted.get` with a bad table name, `.db.splayed.set` into a missing directory, and the same with a 200-byte directory name, shown by its tail and under 256 bytes. - **`alter` on a shared value:** `rfl/system/error_messages_named` also runs `alter` out of range on a value another name shares. - **`lang/col_file_messages`** (new, `test/test_lang.c`): a column file cut short answers `corrupt` with `the file is shorter than its data`; a missing one answers `io` with the path and `No such file or directory`. On dev both fail: every one of these messages is empty there. The review's cases (a truncated splayed column, `.d` schema and parted column, `.log.validate`, `.log.open`) are at the end of `rfl/system/error_messages_named`. The tests match a path by its tail, so they hold under any temp root. They pass with `TMPDIR` set to a 100-character directory. **Updated:** `rfl/hof/eval_branch_cov` expected a compiled `set` of a reserved name to answer `{code:reserve msg:""}`. It now expects the message. ## Error codes against dev Every failure case in the tests, run on dev and on this change: 18 cases, every code equal. | case | dev | this change | |---|---|---| | set reserved | `reserve` | `reserve` | | set reserved compiled | `reserve` | `reserve` | | times reserved | `reserve` | `reserve` | | generic null arg | `type` | `type` | | generic null binary | `type` | `type` | | upsert no key column | `value` | `value` | | upsert extra column | `value` | `value` | | insert dict bad key | `value` | `value` | | graph.build no src | `name` | `name` | | graph.build no weight | `name` | `name` | | split over 256 | `limit` | `limit` | | alter out of range | `index` | `index` | | alter shared out of range | `index` | `index` | | parted bad name | `io` | `io` | | splayed set missing dir | `io` | `io` | | splayed set long dir | `io` | `io` | | log roll no journal | `domain` | `domain` | | log sync no journal | `ok` | `ok` | ## Checks - gcc release and debug builds; `make -j4 test TEST_ARGS="-j 4"`: 5936 of 5940 passed (4 skipped, 0 failed). - `make docs-check`: pages current. - `clang-23 -fsyntax-only -Werror` on the changed C files. - ASan full suite: 7536 of 7540 passed (4 skipped, 0 failed). Fixes #1886
singaraiona
left a comment
There was a problem hiding this comment.
Review of b5f5bc1: NEEDS CHANGES
The location is back on every failure, but on a long directory the reason it was added for now falls off the end of the 255-byte message.
Finding
- A long directory pushes the reason out of the splayed and parted column messages (
src/store/splay.c, both newfailed to load: %s/cannot read .d schema: %sarms).- The prefix (
splayed <dir>: column 'a' failed to load:) is now always added, and the loader's own message follows it. For a column file the loader's message already names the full column path (column "<path>": …), so the path is printed twice:- the directory, cut to 72 bytes;
- then the column path, cut to 120 bytes.
The message then reaches the 255-byte cap before the reason.
- I ran it with a fixture root of 114 bytes (a long temp root, as on macOS). These 11 cases end at exactly 255 bytes with the reason cut:
- a missing column:
…/miss//b": cannot map the - truncated columns (
tr40,tr20), truncated SYM and STR columns (sym,str,trsym,trstr) and a bad parted column (pbad):the file is sho - an empty file and a column that is a directory:
cannot map the - a bad version byte:
format byte and g - a missing parted column (
pmiss):cannot map the - a truncated
.dschema:the file is shorter
- a missing column:
- With a missing table directory, the
.dmessage ends atcannot map the fileand loses: No such file or directory. - Only the list-column cases keep their reason (152–176 bytes), because the deserializer's message carries no path.
- The reason survives only while the directory stays under about 78 bytes, so the requirement that a long directory keeps the reason visible does not hold.
- Fix: don't print the path twice. The prefix already names the directory and the column, so when the loader's message starts with
column ", keep only the text after its first":(the reason). Alternatively, give the prefix a tighter bound. Either way the tail of the directory, the column and the full reason fit. - Test: put the rfl cases under a directory of about 150 bytes (the 200-byte
.db.splayed.setcase already builds one) and check that the message ends with the reason, for a missing column and for a truncated one.
- The prefix (
What I checked
Range-diff against 9665a6f. It holds only:
- the splay.c prefixing (column and
.dschema); err_to_ray_pathfor.log.validateand.log.open;- the new rfl lines;
- the rebase, with
errpath.hnow coming from dev via #1884 and thetest_lang.centries kept both; - the commit message.
The repro. On a short root, the truncated list column in a splayed table and in a parted partition answers corrupt splayed <dir>: column 'l' failed to load: column file: the vector header is truncated, as claimed.
Memory safety. The loader's message is copied into a local why[256] with snprintf before ray_error_free. The column name is printed %.*s from the schema string, which is still held. The directory is the caller's and goes through ray_err_path_n into a stack buffer of RAY_ERR_PATH_MAX + 1. err_to_ray_path bounds the path the same way. Everything is bounded, and nothing is read after its release.
Codes. Last round's 72 cases plus four more (a truncated .d, .log.open in its two-argument form, a column with a long name, a parted list column), on dev (2ed4637) and on this head: all 76 codes are equal.
Journal messages. .log.validate "<path>" and .log.open "<path>" now name the path, bounded.
Tests. No new test line embeds a full temp path: the patterns match by tail (*emn/s/, */nolog.log). These pass:
error_messages_namedandlang/col_file_messages;- the splay, parted and journal tests (476 tests, 1 skipped).
Not covered
- A full suite this round.
- ASan for this round's diff: I only read it.
- Windows and macOS.
…ation and the reason ## The defect 267 sites in `src` raised an error with an empty `msg`, outside the parse and file builtins that #1884 fixes. A script that caught one had only a code to report: `(set .sys.gc 1)` gave `{code:reserve msg:""}`, a truncated column file `{code:corrupt msg:""}`, `(split s (til 300))` `{code:limit msg:""}`. The count is of every `ray_error(code, NULL)` or `ray_error(code, "")`, including a code computed at run time (`ray_err_code_str(err)`), without `oom` and `cancel`, whose codes say all there is. ## The fix Each of the 256 sites below now names the operation and the reason, in the style #1884 set, with the path or name where there is one. **Codes do not change.** | family | sites | for example, now | |---|---:|---| | language (`src/lang`) | 53 | `set: cannot bind '.sys.gc' (reserve)`; `times: '.sys.gc' is a reserved name`; `neg: the generic null is not an argument; only nil?, type and ser take it`; `call: an argument answered no value` for a callee's C NULL | | plan execution | 59 | `join: a side of more than 2147483647 rows is not supported`; `execute: plan opcode N is not implemented`; `parted execute: the columns disagree on the number of partitions` | | column files and storage | 62 | `column file: the vector data is truncated (N bytes needed, M left)`; `column "<path>": cannot map the file: <reason>`; `.db.splayed.set "<dir>": the save failed (io)`; `.log.roll: the journal failed (io)`; `parted load: table name 'a/b' must be a plain name …` | | graph | 49 | `dijkstra: the graph has no edge properties; build it with a weight column`; `graph.build: the table has no src column 'src'` | | query | 19 | `upsert: the payload has no key column 'k'`; `insert: the row's key 'zz' is not a column of the table`; `let: cannot bind a local (reserve)` | | values | 14 | `split: more than 256 cut positions, got 300`; `alter: index 9 is out of range for length 3`; `as: the target type symbol has no text` | **The plan-execution sites cost nothing on success.** Most there, and the language family's `x ? x : ray_error(...)` fallbacks, are reached only when an invariant fails or a callee answers a C NULL. A message is formatted only on that path. ## The rules from the review of #1884, applied here - **The OS reason is the failing call's own.** - `ray_vm_map_file` (POSIX and WASM, `src/core/platform.c`) keeps the failing call's `errno` across its `close`, and leaves 0 for an empty file. So the column loader's `cannot map the file: <reason>` names the real reason, or `the file is empty`. The Windows map sets no `errno`, so there the message says `the file cannot be mapped`. - `.db.splayed.set` reads no `errno`, because the save's cleanup makes calls after the failing one. It names the code: `the save failed (io)`. - The journal builtins, whose store answers a code only, likewise name the operation and the code (`err_to_ray`). - **A value is read before it is released.** `alter`'s out-of-range message reads the target's length before its release (`tblop.c`, the audit's finding). A target whose value another name shares is in the test. - **Symbol names are printed with their length** (`%.*s`), never as a bare string. - **A long path never pushes out the reason.** Paths go through `ray_err_path` (`src/core/errpath.h`, the same file #1884 adds), which shows a path over 120 bytes by its tail, cut at a character boundary. That covers the column loader's messages, the existing `column %s: …` ones included, the splayed append and the parted load. ## A column's file, table and column, kept (review of #1887) The column reader's new messages say what is wrong but not which file. The table loader used to add the directory and the column only to a message-less error. Now it always does, and adds the reader's reason after them, so nothing dev said is lost: - **A splayed column:** `splayed <dir>: column 'l' failed to load: column file: the vector header is truncated`, where dev said `splayed <dir>: column 'l' failed to load`. - **A parted table:** its partitions load through the same loader, so the message names the partition's directory. - **The `.d` schema:** `splayed <dir>: cannot read .d schema: <reason>`. - **The other loaders that read a column file:** the retired-names list and the file-local symbol codes swallow their errors by design (best effort). The graph's CSR loader answers a code only through the C API. Neither loses a message. - **The journal builtins given a path:** `.log.validate` and `.log.open` name it: `.log.validate "<path>": the journal failed (io)`. - **The path once, and the reason always** (second review): the loader's own lead, `column "<path>": ` or `column file: `, is left out after the table loader's prefix (`splay_col_reason`). So the path is not given twice, and the directory is shown by its tail. - **Every `column %s: ...` message in the column loaders** shows its path by its tail, so the reason never falls outside the 255 bytes even before a prefix is added: - the generation-2 reader's (`enccol.c`, 21 messages); - `col.c`'s symfile ones; - the region writer's (`colwrite.c`); - the string-domain and STR-selection ones (`strdom.c`, `exec.c`). - **Test:** under a directory of about 150 bytes, each of seven damaged columns and `.d` schemas, and a parted column, keeps its reason: a truncated vector, a file shorter than its header, a missing file, a truncated list header, an empty file, a truncated or missing `.d`. Each message is under 256 bytes, in both the generation-0 and the generation-2 runs, and with a 100-character `TMPDIR`. Codes are unchanged: a truncated splayed column, `.d` schema and parted column answer `corrupt`, and the two journal cases `io`, as on dev. ## Left empty on purpose (11) - **`raise`** (`ray_raise_fn`): its error carries the raised value, which IPC renders into the reply. - **`return`** (`ray_return_fn`): control flow. - **The error-copying helpers**, which rebuild an error with its own message or with none: `lazy_error_copy`, `ray_retain_owned_refs`, `pq_task_msg_raise`, `ray_enc_snap_error`, and `de_raw_inner` ×2, which keeps a peer's error as it was sent. - **The column loader's three message-less `nyi` refusals** (`col.c`): `splay.c` takes a message-less `nyi` as "retry with the copying loader", a contract. The 28 sites #1884 fixes are not touched here. ## Tests - **`rfl/system/error_messages_named`** (new) asserts code and `msg` for a sample of each family: - `set` (tree-walked and compiled) and `times` on a reserved name, and the generic null as an argument; - `upsert` and `insert` payloads, and `.graph.build` with no `src` column; - `split` over 256 cut positions, and an `alter` index out of range; - `.db.parted.get` with a bad table name, `.db.splayed.set` into a missing directory, and the same with a 200-byte directory name, shown by its tail and under 256 bytes. - **`alter` on a shared value:** `rfl/system/error_messages_named` also runs `alter` out of range on a value another name shares. - **`lang/col_file_messages`** (new, `test/test_lang.c`): a column file cut short answers `corrupt` with `the file is shorter than its data`; a missing one answers `io` with the path and `No such file or directory`. On dev both fail: every one of these messages is empty there. The review's cases (a truncated splayed column, `.d` schema and parted column, `.log.validate`, `.log.open`) are at the end of `rfl/system/error_messages_named`. The tests match a path by its tail, so they hold under any temp root. They pass with `TMPDIR` set to a 100-character directory. **Updated:** `rfl/hof/eval_branch_cov` expected a compiled `set` of a reserved name to answer `{code:reserve msg:""}`. It now expects the message. ## Error codes against dev Every failure case in the tests, run on dev and on this change: 18 cases, every code equal. | case | dev | this change | |---|---|---| | set reserved | `reserve` | `reserve` | | set reserved compiled | `reserve` | `reserve` | | times reserved | `reserve` | `reserve` | | generic null arg | `type` | `type` | | generic null binary | `type` | `type` | | upsert no key column | `value` | `value` | | upsert extra column | `value` | `value` | | insert dict bad key | `value` | `value` | | graph.build no src | `name` | `name` | | graph.build no weight | `name` | `name` | | split over 256 | `limit` | `limit` | | alter out of range | `index` | `index` | | alter shared out of range | `index` | `index` | | parted bad name | `io` | `io` | | splayed set missing dir | `io` | `io` | | splayed set long dir | `io` | `io` | | log roll no journal | `domain` | `domain` | | log sync no journal | `ok` | `ok` | ## Checks - gcc release and debug builds; `make -j4 test TEST_ARGS="-j 4"`: 5936 of 5940 passed (4 skipped, 0 failed). - `make docs-check`: pages current. - `clang-23 -fsyntax-only -Werror` on the changed C files. - ASan full suite: 7536 of 7540 passed (4 skipped, 0 failed). Fixes #1886
b5f5bc1 to
7195c97
Compare
singaraiona
left a comment
There was a problem hiding this comment.
Review of 7195c97: READY
The finding is fixed: a long directory no longer pushes the reason out.
The 114-byte-root repro. I re-ran my cases under a 114-byte fixture root on this head and on dev (2ed4637). Every message ends with its reason, at 139–163 bytes, and all 16 codes equal dev:
- the 11 cases cut at 255 bytes last round: a missing column; truncated columns (
tr40,tr20); truncated SYM and STR columns; an empty file; a bad version byte; a column that is a directory; a truncated.d; a bad and a missing parted column; - plus a missing table directory, the list column and the parted list column.
For example:
splayed ...<tail>/miss/: column 'b' failed to load: cannot map the file: No such file or directorysplayed ...<tail>/schm/: cannot read .d schema: the file is shorter than its 32-byte header
The stripping (splay_col_reason) is safe.
- It only ever returns a pointer into the message it was given, after a
strncmpon the lead. - An empty message returns
"", sowhystays empty and the plain prefix is used. - A lead with no closing
":(quoted) or:(unquoted) returns the message whole. - A directory whose name contains
":would only shift where the cut falls, still inside the copied, boundedwhy[256]. - I listed every
ray_errormessage in the column loaders that startscolumnwithout a path. Onlycolumn load: no path/column map: no pathandcolumn ?: no DICT indexexist; none of them loses information when cut, and the first two need a NULL path, which the splayed loader never passes.
Diff since b5f5bc1. It holds only:
splay_col_reasonand its two call sites;EPATHon thecolumn %s: …messages in enccol.c and exec.c (with the wrapping removed, those hunks are identical apart from the includes), and in strdom.c, colwrite.c and col.c's two symfile messages;- the new rfl block (damaged columns and
.dunder a long directory, in both format generations).
Sanitizers. Under ASan+UBSan (make test-full-bin, setarch -R) these all pass with no report:
error_messages_namedandlang/col_file_messages;- the splay, parted, col and enc tests (1,003 tests, 1 skipped);
- my repro script.
Not covered: a full gcc suite this round (last round's passed), Windows and macOS.
…ation and the reason ## The defect 267 sites in `src` raised an error with an empty `msg`, outside the parse and file builtins that #1884 fixes. A script that caught one had only a code to report: `(set .sys.gc 1)` gave `{code:reserve msg:""}`, a truncated column file `{code:corrupt msg:""}`, `(split s (til 300))` `{code:limit msg:""}`. The count is of every `ray_error(code, NULL)` or `ray_error(code, "")`, including a code computed at run time (`ray_err_code_str(err)`), without `oom` and `cancel`, whose codes say all there is. ## The fix Each of the 256 sites below now names the operation and the reason, in the style #1884 set, with the path or name where there is one. **Codes do not change.** | family | sites | for example, now | |---|---:|---| | language (`src/lang`) | 53 | `set: cannot bind '.sys.gc' (reserve)`; `times: '.sys.gc' is a reserved name`; `neg: the generic null is not an argument; only nil?, type and ser take it`; `call: an argument answered no value` for a callee's C NULL | | plan execution | 59 | `join: a side of more than 2147483647 rows is not supported`; `execute: plan opcode N is not implemented`; `parted execute: the columns disagree on the number of partitions` | | column files and storage | 62 | `column file: the vector data is truncated (N bytes needed, M left)`; `column "<path>": cannot map the file: <reason>`; `.db.splayed.set "<dir>": the save failed (io)`; `.log.roll: the journal failed (io)`; `parted load: table name 'a/b' must be a plain name …` | | graph | 49 | `dijkstra: the graph has no edge properties; build it with a weight column`; `graph.build: the table has no src column 'src'` | | query | 19 | `upsert: the payload has no key column 'k'`; `insert: the row's key 'zz' is not a column of the table`; `let: cannot bind a local (reserve)` | | values | 14 | `split: more than 256 cut positions, got 300`; `alter: index 9 is out of range for length 3`; `as: the target type symbol has no text` | **The plan-execution sites cost nothing on success.** Most there, and the language family's `x ? x : ray_error(...)` fallbacks, are reached only when an invariant fails or a callee answers a C NULL. A message is formatted only on that path. ## The rules from the review of #1884, applied here - **The OS reason is the failing call's own.** - `ray_vm_map_file` (POSIX, that is Linux and macOS, and WASM, `src/core/platform.c`, which now includes `<errno.h>` for each, not only under Linux) keeps the failing call's `errno` across its `close`, and leaves 0 for an empty file. So the column loader's `cannot map the file: <reason>` names the real reason, or `the file is empty`. The Windows map sets no `errno`, so there the message says `the file cannot be mapped`. - `.db.splayed.set` reads no `errno`, because the save's cleanup makes calls after the failing one. It names the code: `the save failed (io)`. - The journal builtins, whose store answers a code only, likewise name the operation and the code (`err_to_ray`). - **A value is read before it is released.** `alter`'s out-of-range message reads the target's length before its release (`tblop.c`, the audit's finding). A target whose value another name shares is in the test. - **Symbol names are printed with their length** (`%.*s`), never as a bare string. - **A long path never pushes out the reason.** Paths go through `ray_err_path` (`src/core/errpath.h`, the same file #1884 adds), which shows a path over 120 bytes by its tail, cut at a character boundary. That covers the column loader's messages, the existing `column %s: …` ones included, the splayed append and the parted load. ## A column's file, table and column, kept (review of #1887) The column reader's new messages say what is wrong but not which file. The table loader used to add the directory and the column only to a message-less error. Now it always does, and adds the reader's reason after them, so nothing dev said is lost: - **A splayed column:** `splayed <dir>: column 'l' failed to load: column file: the vector header is truncated`, where dev said `splayed <dir>: column 'l' failed to load`. - **A parted table:** its partitions load through the same loader, so the message names the partition's directory. - **The `.d` schema:** `splayed <dir>: cannot read .d schema: <reason>`. - **The other loaders that read a column file:** the retired-names list and the file-local symbol codes swallow their errors by design (best effort). The graph's CSR loader answers a code only through the C API. Neither loses a message. - **The journal builtins given a path:** `.log.validate` and `.log.open` name it: `.log.validate "<path>": the journal failed (io)`. - **The path once, and the reason always** (second review): the loader's own lead, `column "<path>": ` or `column file: `, is left out after the table loader's prefix (`splay_col_reason`). So the path is not given twice, and the directory is shown by its tail. - **Every `column %s: ...` message in the column loaders** shows its path by its tail, so the reason never falls outside the 255 bytes even before a prefix is added: - the generation-2 reader's (`enccol.c`, 21 messages); - `col.c`'s symfile ones; - the region writer's (`colwrite.c`); - the string-domain and STR-selection ones (`strdom.c`, `exec.c`). - **Test:** under a directory of about 150 bytes, each of seven damaged columns and `.d` schemas, and a parted column, keeps its reason: a truncated vector, a file shorter than its header, a missing file, a truncated list header, an empty file, a truncated or missing `.d`. Each message is under 256 bytes, in both the generation-0 and the generation-2 runs, and with a 100-character `TMPDIR`. Codes are unchanged: a truncated splayed column, `.d` schema and parted column answer `corrupt`, and the two journal cases `io`, as on dev. ## Left empty on purpose (11) - **`raise`** (`ray_raise_fn`): its error carries the raised value, which IPC renders into the reply. - **`return`** (`ray_return_fn`): control flow. - **The error-copying helpers**, which rebuild an error with its own message or with none: `lazy_error_copy`, `ray_retain_owned_refs`, `pq_task_msg_raise`, `ray_enc_snap_error`, and `de_raw_inner` ×2, which keeps a peer's error as it was sent. - **The column loader's three message-less `nyi` refusals** (`col.c`): `splay.c` takes a message-less `nyi` as "retry with the copying loader", a contract. The 28 sites #1884 fixes are not touched here. ## Tests - **`rfl/system/error_messages_named`** (new) asserts code and `msg` for a sample of each family: - `set` (tree-walked and compiled) and `times` on a reserved name, and the generic null as an argument; - `upsert` and `insert` payloads, and `.graph.build` with no `src` column; - `split` over 256 cut positions, and an `alter` index out of range; - `.db.parted.get` with a bad table name, `.db.splayed.set` into a missing directory, and the same with a 200-byte directory name, shown by its tail and under 256 bytes. - **`alter` on a shared value:** `rfl/system/error_messages_named` also runs `alter` out of range on a value another name shares. - **`lang/col_file_messages`** (new, `test/test_lang.c`): a column file cut short answers `corrupt` with `the file is shorter than its data`; a missing one answers `io` with the path and `No such file or directory`. On dev both fail: every one of these messages is empty there. The review's cases (a truncated splayed column, `.d` schema and parted column, `.log.validate`, `.log.open`) are at the end of `rfl/system/error_messages_named`. The tests match a path by its tail, so they hold under any temp root. They pass with `TMPDIR` set to a 100-character directory. **Updated:** `rfl/hof/eval_branch_cov` expected a compiled `set` of a reserved name to answer `{code:reserve msg:""}`. It now expects the message. ## Error codes against dev Every failure case in the tests, run on dev and on this change: 18 cases, every code equal. | case | dev | this change | |---|---|---| | set reserved | `reserve` | `reserve` | | set reserved compiled | `reserve` | `reserve` | | times reserved | `reserve` | `reserve` | | generic null arg | `type` | `type` | | generic null binary | `type` | `type` | | upsert no key column | `value` | `value` | | upsert extra column | `value` | `value` | | insert dict bad key | `value` | `value` | | graph.build no src | `name` | `name` | | graph.build no weight | `name` | `name` | | split over 256 | `limit` | `limit` | | alter out of range | `index` | `index` | | alter shared out of range | `index` | `index` | | parted bad name | `io` | `io` | | splayed set missing dir | `io` | `io` | | splayed set long dir | `io` | `io` | | log roll no journal | `domain` | `domain` | | log sync no journal | `ok` | `ok` | ## Checks - gcc release and debug builds; `make -j4 test TEST_ARGS="-j 4"`: 5936 of 5940 passed (4 skipped, 0 failed). - `make docs-check`: pages current. - `clang-23 -fsyntax-only -Werror` on the changed C files. - ASan full suite: 7536 of 7540 passed (4 skipped, 0 failed). Fixes #1886
7195c97 to
93e6ece
Compare
|
Carry-over: 93e6ece is 7195c97 (Review of 7195c97: READY) on the same parent with only the macOS build fix: src/core/platform.c gains #include <errno.h> in the shared Linux/macOS include list and in the WASM block, test/test_lang.c wraps test_col_file_messages' body in #if !defined(RAY_OS_WINDOWS) instead of an early PASS, and one line of the message says so. |
The defect
267 sites in
srcraised an error with an emptymsg, outside the parse and file builtins that #1884 fixes. A script that caught one had only a code to report:(set .sys.gc 1)gave{code:reserve msg:""}, a truncated column file{code:corrupt msg:""},(split s (til 300)){code:limit msg:""}.The count is of every
ray_error(code, NULL)orray_error(code, ""), including a code computed at run time (ray_err_code_str(err)), withoutoomandcancel, whose codes say all there is.The fix
Each of the 256 sites below now names the operation and the reason, in the style #1884 set, with the path or name where there is one. Codes do not change.
src/lang)set: cannot bind '.sys.gc' (reserve);times: '.sys.gc' is a reserved name;neg: the generic null is not an argument; only nil?, type and ser take it;call: an argument answered no valuefor a callee's C NULLjoin: a side of more than 2147483647 rows is not supported;execute: plan opcode N is not implemented;parted execute: the columns disagree on the number of partitionscolumn file: the vector data is truncated (N bytes needed, M left);column "<path>": cannot map the file: <reason>;.db.splayed.set "<dir>": the save failed (io);.log.roll: the journal failed (io);parted load: table name 'a/b' must be a plain name …dijkstra: the graph has no edge properties; build it with a weight column;graph.build: the table has no src column 'src'upsert: the payload has no key column 'k';insert: the row's key 'zz' is not a column of the table;let: cannot bind a local (reserve)split: more than 256 cut positions, got 300;alter: index 9 is out of range for length 3;as: the target type symbol has no textThe plan-execution sites cost nothing on success. Most there, and the language family's
x ? x : ray_error(...)fallbacks, are reached only when an invariant fails or a callee answers a C NULL. A message is formatted only on that path.The rules from the review of #1884, applied here
ray_vm_map_file(POSIX, that is Linux and macOS, and WASM,src/core/platform.c, which now includes<errno.h>for each, not only under Linux) keeps the failing call'serrnoacross itsclose, and leaves 0 for an empty file. So the column loader'scannot map the file: <reason>names the real reason, orthe file is empty. The Windows map sets noerrno, so there the message saysthe file cannot be mapped..db.splayed.setreads noerrno, because the save's cleanup makes calls after the failing one. It names the code:the save failed (io).err_to_ray).alter's out-of-range message reads the target's length before its release (tblop.c, the audit's finding). A target whose value another name shares is in the test.%.*s), never as a bare string.ray_err_path(src/core/errpath.h, the same file fix(lang): parse and read errors say what went wrong and where, as read-value and load do #1884 adds), which shows a path over 120 bytes by its tail, cut at a character boundary. That covers the column loader's messages, the existingcolumn %s: …ones included, the splayed append and the parted load.A column's file, table and column, kept (review of #1887)
The column reader's new messages say what is wrong but not which file. The table loader used to add the directory and the column only to a message-less error. Now it always does, and adds the reader's reason after them, so nothing dev said is lost:
splayed <dir>: column 'l' failed to load: column file: the vector header is truncated, where dev saidsplayed <dir>: column 'l' failed to load..dschema:splayed <dir>: cannot read .d schema: <reason>..log.validateand.log.openname it:.log.validate "<path>": the journal failed (io).column "<path>":orcolumn file:, is left out after the table loader's prefix (splay_col_reason). So the path is not given twice, and the directory is shown by its tail.column %s: ...message in the column loaders shows its path by its tail, so the reason never falls outside the 255 bytes even before a prefix is added:enccol.c, 21 messages);col.c's symfile ones;colwrite.c);strdom.c,exec.c)..dschemas, and a parted column, keeps its reason: a truncated vector, a file shorter than its header, a missing file, a truncated list header, an empty file, a truncated or missing.d. Each message is under 256 bytes, in both the generation-0 and the generation-2 runs, and with a 100-characterTMPDIR.Codes are unchanged: a truncated splayed column,
.dschema and parted column answercorrupt, and the two journal casesio, as on dev.Left empty on purpose (11)
raise(ray_raise_fn): its error carries the raised value, which IPC renders into the reply.return(ray_return_fn): control flow.lazy_error_copy,ray_retain_owned_refs,pq_task_msg_raise,ray_enc_snap_error, andde_raw_inner×2, which keeps a peer's error as it was sent.nyirefusals (col.c):splay.ctakes a message-lessnyias "retry with the copying loader", a contract.The 28 sites #1884 fixes are not touched here.
Tests
rfl/system/error_messages_named(new) asserts code andmsgfor a sample of each family:set(tree-walked and compiled) andtimeson a reserved name, and the generic null as an argument;upsertandinsertpayloads, and.graph.buildwith nosrccolumn;splitover 256 cut positions, and analterindex out of range;.db.parted.getwith a bad table name,.db.splayed.setinto a missing directory, and the same with a 200-byte directory name, shown by its tail and under 256 bytes.alteron a shared value:rfl/system/error_messages_namedalso runsalterout of range on a value another name shares.lang/col_file_messages(new,test/test_lang.c): a column file cut short answerscorruptwiththe file is shorter than its data; a missing one answersiowith the path andNo such file or directory.On dev both fail: every one of these messages is empty there. The review's cases (a truncated splayed column,
.dschema and parted column,.log.validate,.log.open) are at the end ofrfl/system/error_messages_named.The tests match a path by its tail, so they hold under any temp root. They pass with
TMPDIRset to a 100-character directory.Updated:
rfl/hof/eval_branch_covexpected a compiledsetof a reserved name to answer{code:reserve msg:""}. It now expects the message.Error codes against dev
Every failure case in the tests, run on dev and on this change: 18 cases, every code equal.
reservereservereservereservereservereservetypetypetypetypevaluevaluevaluevaluevaluevaluenamenamenamenamelimitlimitindexindexindexindexioioioioioiodomaindomainokokChecks
make -j4 test TEST_ARGS="-j 4": 5936 of 5940 passed (4 skipped, 0 failed).make docs-check: pages current.clang-23 -fsyntax-only -Werroron the changed C files.Fixes #1886