modus
Menu
On this page

The entry errors

A process that shows the errors of the system: one case for each kind of error. Each case makes the error for real, and shows the sentence of the error record that the system gave.

The cases: kernel operations that the kernel refuses (a right, a handle that was revoked or closed, a budget that cannot pay, an address, a size, a flag); loads that fail (a missing import, a replacement that fails its check); a direct call of a module export that fails; isolated calls of the storage service that fail; and a process that faults three calls deep, with its stack trace.

The process runs each case at its start. A key from a to y, or a click on a case, runs it again.

What it is for. In this system an error is a value, not a number to look up: each failed call gives an error record with an error kind, the argument that caused it, the value that it had and the limit that it passed, and the console writes it as a sentence. This process makes 25 real errors, one of each family, and checks that each one gives the record that the contract states . There is no global last error: the record comes back with the call.

What a reader sees. Start it from the start menu, or with start("errors") in the console. The window lists the cases on pages (Tab shows the next page; a page holds the cases that fit in its height): for each one, what the process does, the kind that it expects, and the whole sentence of the record that it got, on as many lines as it needs, in the color "failed" when the answer is not the expected one. The log has one line for each case (errors: a map the boot image to write: ...), then errors: ok, 25 cases, each with the expected error record, the stack trace of the fault case, a case under contention, and the measures of the cost of an error.

The families of cases:

  • kernel operations that the kernel refuses: a right, a handle that was revoked or closed, a handle of the wrong kind, a number that names no handle, a budget that cannot pay, an address in the kernel half, a name too long, an unknown flag, an unknown operation, the pages of another process;
  • load errors: a missing import, a replacement that fails its check;
  • a direct call of a module export that fails (square_root(-4) of the module math);
  • calls of the storage service that fail: an empty name, a name too long, a zero byte, a write over the limit of the store, an absent name;
  • the other families of calls: a wrapper of src/library/modus/system, a ring of the root service, an export of a service (tally.add);
  • a fault three calls deep, with its stack trace from the debug image.

The case under contention. Two threads make failures on handles that a third thread closes and makes again, for a short time. Each record must explain its status; a record of the kind Refused (its cause was gone when the kernel read the state again) must stay rare.

The table of error details of a kernel command. Memory_Create with two wrong arguments, a budget that names nothing and an unknown flag, gives the two in its table of error details, one log line for each; a command with a table that succeeds leaves the table empty; Log, whose last value is an argument, refuses a table.

A full completion queue. The process fills the completion queue of its kernel ring and leaves it unread: the kernel keeps the next command unrun in the command queue and ends the entry with no wait, also on the word of a Word_Wait of the same entry; a kernel call of the library is refused with Busy and does not run; a wait of the library ends at once and pushes nothing; and after the read each answer has come once, in order, and the kept command runs once. Its child stops on a kernel ring that holds records, and its stop must be a stop of itself, not a fault.

The measures, printed and never compared to a bound: a kernel operation that succeeds and one that fails with its record; a direct call that succeeds and one that fails; a refused Log over the limit of a budget, measured by a child (a process of this module with no log records in its budget); a refused Memory_Create, with the takes of the locks of the kernel; a kernel command that succeeds and one that is refused, each with no table of error details and with one.

Its grants, one for each family: Store (the cases of the storage service), Image (load modules, and start its child and the process fault), Inspect (the counts of the locks, the pages of another process), Connect (ask the root service for a connection that it refuses: the root service lets it call no service), and Debug_Image (the names of the stack trace). Its log handle has the right Give, for its child.

See: Module contract: Errors that diagnose

errors module with an entry

Hash
60e306825d7f55be0501dd6b64192e81fada9c241fc5269a1accf150027bef4b
Size
435769 bytes
Exports
0
Imports
0
Imported by
0
License
MIT

A process that shows the errors of the system: one case for each kind of error

FactValue
KindModules with an entry
Sourcesrc/modules/demonstrations/errors
Boot imageyes: in the boot image, 435769 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
entry()runs every case once, then the measures, then shows the cases in a window until the process is stopped

entry

entry()

entry runs every case once, then the measures, then shows the cases in a window until the process is stopped.

When it is the child (the value VALUE_CHILD of its context is not 0), it only runs the refused Log operations of the measure (child) and stops with Done.

Else, in order:

  1. 1. It opens its window, and maps the boot image and the debug image.
  2. 2. It connects to its private store, loads the modules math and tally, and opens the ring of the root service.
  3. 3. It runs each case (run) and writes one log line for each, then the summary: errors: ok, 25 cases, each with the expected error record, or the count of the cases that gave another answer.
  4. 4. It runs the case under contention (contend), then the measures (measure, families_measure, refusals), and writes the times in nanoseconds.
  5. 5. It draws the window at each event. Tab shows the next page; a key from a to y, or a press on a case, runs that case again and writes its new sentence.

The stop: with no random seed, it stops with Refused; with no window, with Failed. Else it never returns. A wrong case does not stop it: the log says WRONG: before the sentence.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/demonstrations/errors/main.odin:1288

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsIt makes errors in its store, loads modules and starts fault from the boot image, counts the locks, and asks for connections that this service refuses (its start grant set names no service). One object is over the limit of its store. It gives the log to its child, which measures a refused Log.
Other terms of its start grant setstore_blocks = 2, log_gives = true
Budget that it asks for
  • working memory pages 1830
  • pages of its threads 129
  • pages of the pictures of its window 5500
  • pages of the module and its imports from the files of the build
  • processes 3
  • threads 4
It starts fault and its child, and 3 threads under contention: 1476 pages. And the glyph memory of the copy of the text rendering of the drawing module, which draws its text: 354 pages (display.TEXT_MEMORY_PAGES). 1476 + 354 = 1830.

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

Error_Record struct

A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

add procedure of the package tally

add :: proc "c" (amount: i64, note: ^string, error: ^errors.) -> i64

add adds an amount to the count, with a note that says why.

src/modules/demonstrations/tally/main.odin:79

families_measure procedure of the package errors_process

families_measure :: proc "contextless" (ctx: ^system.Context)

A procedure with no comment in its source.

src/modules/demonstrations/errors/main.odin:727