17. Divergences from native ooRexx


17. Divergences from native ooRexx

This chapter catalogues every known case where the RVM, on purpose or knowingly, behaves differently from native ooRexx 5 (the oracle). It assumes the value model (02), the machine (05) and the object core (08). Features that are simply missing are not divergences: they are in 18-known-gaps.md. Defects of native ooRexx that the RVM does not reproduce are mentioned only where the difference is visible to a correct program (Native defects).

Reading an entry

Each entry gives the native behaviour, the RVM behaviour, the hosts that show it, its status and the reason.

Status Meaning
Accepted a design decision; it is not going to change. Where the official test suite notices it, a rule of the census filter accepts it (ooTest acceptance rules).
Open the RVM falls short; no decision keeps it that way. Fixing it is welcome.
Pending decision the baseline behaviour, kept until the owner decides whether it becomes accepted or is fixed; listed together under Open: pending decision, with the reason the RVM behaves so. Other chapters describe the behaviour and link there; they call it neither a bug nor accepted.

Hosts: both (the ooRexx host, rvm, and the JS host, js/rvm), JS or ooRexx host. Every entry with a code example below was checked with a probe against both hosts and native rexx.

Principles

A few design decisions generate whole families of divergences; the entries cite them.

  • P1. When in doubt, ooRexx. The RVM follows native ooRexx, not the ANSI standard, wherever they differ (e.g. whole-number checks look at the rounded value: 02; the errors of the built-in functions are native's, not the standard's 40.x: Native defects kept), so that native stays usable as the oracle for everything.
  • P2. No hidden representations of numbers. Native ooRexx has RexxInteger, NumberString and RexxString, and the RexxInteger fast paths are sometimes observable. The RVM has one observable value and follows the standard (its internal Integer is an optimisation that cannot change a result: 02).
  • P3. In the JS host a string is its value. Strings have no identity there.
  • P4. Determinism. Inter-activity order is the RVM's own, and a virtual clock exists for tests (07).
  • P5. Libraries are not the language. The RVM ships the libraries that programs and the test suite need (REXXUTIL, rxmath, rxregexp, rxsock, hostemu, csvStream, json...), not every native one (12).

Numbers

MIN and MAX of whole numbers (P2)

  • Native: RexxInteger's fast path: MIN of a single whole number is not rounded to DIGITS (at DIGITS 3, min(12345) and 12345~min are 12345; max(12345) is 1.23E+4), and MAX/MIN of whole numbers ignore FUZZ (at FUZZ 1, max(100,101) is 101), and a hole among the arguments after whole numbers only is 93.903 naming the argument before it ("argument 0" for MAX(1,,3); MAX('1.5',,3) is 40.5 "argument 1").
  • RVM: the NumberString path for all: 1.23E+4; at FUZZ 1 max(100,101) is 100 and min(101,100) is 101 (equal under FUZZ: the first wins); a hole is 40.5.
  • Hosts: both. Status: accepted (rule REXXINTEGER). Reason: P2; the result follows the standard and native's own NumberString path. The ooRexx source comments the RexxInteger shortcut as intentional.

Strings, identity and hashing

IdentityTable and string identity (P3)

  • Native: strings are objects with identity: "22" and "2"||"2" are two different indexes of an IdentityTable; "2" stored as an item and "1223"~substr(2,1) are different items (literals are interned, so a literal stored and looked up is the same object).
  • RVM: JS: equal strings are the same index and the same item (two puts give one entry). ooRexx host: indexes are told apart (the host's IdentityTable) but items are not, since host strings keep no identity from a literal to a variable; HASITEM, INDEX and REMOVEITEM compare string items by value in both hosts.
  • Hosts: both (indexes: JS only). Status: accepted (rule STRID). Reason: P3; giving JS strings identity would mean boxing every string.

Iteration order of hashed collections with object indexes

  • Native: IdentityTable, and Table/Set/Bag/Relation indexed by objects without a Rexx HASHCODE, iterate in the order of the objects' addresses.
  • RVM: ooRexx host: the host collection's order for its objects; JS: creation order of the objects. String indexes iterate in native order in both hosts (10).
  • Hosts: both. Status: accepted. Reason: addresses are not reproducible; no program can rely on them.

HASHCODE of an object

  • Native: the object's address (8 bytes).
  • RVM: its identity number as 8 bytes, little endian. Strings hash as native (getStringHash), and the sequence of HASHCODE and == sends a collection makes for a user-defined index is native's (08).
  • Hosts: both. Status: accepted. Reason: as above.

A metaclass NEW that returns no class

  • Native: a metaclass's own NEW (a class method of the metaclass) that returns an object that is not a class makes SUBCLASS, or a ::CLASS with that METACLASS, crash (segmentation fault).
  • RVM: 93.900 "RVM: the NEW of a metaclass gave no class".
  • Hosts: both. Status: accepted. Reason: a crash is not a behaviour to reproduce (08).

Class methods on a metaclass instance that is no class

  • Native: an object made by Object's NEW from a metaclass (.meta~new:.object) has Class's methods, which read it as a class it is not: ID gives no result (91.999), SUBCLASS 99.927 with a garbage name, METHODS an empty supplier, ISSUBCLASSOF nothing.
  • RVM: COPY, DEFAULTNAME and HASHCODE as native; any other method of Class raises 93.900 "RVM: method NAME of Class on an object that is no class".
  • Hosts: both. Status: accepted. Reason: native's results come from reading memory the object does not have; a clear error is the useful answer (08).

Objects, classes and arguments

STACKFRAMES and RexxContext identifiers

  • Native: INTERPRETER and invocation numbers are the interpreter's internal counters.
  • RVM: INTERPRETER is always 1; invocation numbers are distinct and stable but not native's values. THREAD is the activity number, as native (1 for the program, one per START, REPLY...).
  • Hosts: both. Status: accepted. See 09.

Concurrency, time and UNINIT

See 07 for the mechanisms.

Inter-activity order is deterministic (P4)

  • Native: activities are threads; their interleaving varies from run to run.
  • RVM: the scheduler's order (time slices, ready queue) is the same in every run and on both hosts, except for the clause where an asynchronous HALT lands, which depends on slicing.
  • Hosts: both. Status: accepted. Reason: reproducible runs and testable output.

A wait that nothing can satisfy ends the run

  • Native: .eventSemaphore~new~wait with no other thread hangs forever.
  • RVM: when no activity is ready and no timer or I/O is pending, the run ends (normally, return code 0).
  • Hosts: both. Status: accepted. Reason: the scheduler knows nothing can ever wake the activity.

The virtual clock

  • Native: real time only.
  • RVM: with RVM_CLOCK=virtual the scheduler's clock starts at 0 and jumps to the next timer when nothing is ready; a busy loop does not advance it (an activity spinning while another sleeps keeps the sleeper asleep), and TIME/DATE add the skipped time. The default is the real clock.
  • Hosts: both. Status: accepted. Reason: P4; deterministic, instant test runs.

Nested waits that cross

  • Native: code run synchronously on behalf of a native (a Rexx HASHCODE or == called by a collection, a security manager, a STRING requested by a native, the target of an ADDRESS WITH) may block like any code, each thread on its own stack; it may also REPLY.
  • RVM: such code runs in a nested machine (runSync/sendSync, 05), and a wait there runs the other activities in place until it can go on (07). The waiting activity's frames are below that pump on the host stack, so an activity run by it that waits, in a nested machine of its own, for something only the first can do after its wait cannot go on: 93.900 "RVM: nested waits cross (an activity waits below this one)", and the first goes on. A wait there that nothing can end is 93.900 "RVM: an activity waits for something that cannot come" (native blocks for ever). (A REPLY there is native's: 07.)
  • Hosts: both. Status: open (a limit of the design, see tests/e2e/cases/e2e-221-nested-cross.rex). Reason: the machine never nests its loop inside a host call (06); the waits nest instead.

Ctrl-C during a blocked read

  • Native: a signal interrupts a blocking read (read gives EINTR): PULL or LINEIN waiting on standard input gives up, and the HALT is raised at once. A command the interpreter waits for is not waited for any more, even when the signal was sent to the interpreter alone (RC is then undefined).
  • RVM: a read of standard input that waits for its reader (a terminal, or any read while something else may run: 07) is cut short as native's; so is, in the ooRexx host, every read (the host interpreter takes the signal). What remains: in the JS host, a read that cannot wait (no worker, RVM_WORKER=0; a pipe read with nothing else to run) gets the HALT when it ends, and a second Ctrl-C ends the process (exit status 130); and a command gets the HALT when it ends: in both hosts one that lets the other activities run (07), in the JS host also one waited for (the ooRexx host stops waiting for it, as native). At a terminal Ctrl-C reaches the writer of the pipe and the command too (the terminal's process group), so these end at once; the difference shows with a signal sent to the interpreter alone.
  • Hosts: both (commands), JS (reads). Status: accepted. Reason: Node has no way to interrupt a synchronous read in another thread, and a reader process for every chunk of a pipe would cost too much; the RVM's command threads cannot be interrupted either, and RC would have no value (07).

UNINIT order and timing

  • Native: UNINIT runs when the garbage collector finds the object unreachable (possibly mid-program), in the order of its internal table.
  • RVM: only at program end, for the objects not reachable from .environment, in creation order (07).
  • Hosts: both. Status: accepted. Reason: the RVM has no garbage collector of its own (objects live while the host holds them, and the RVM holds almost everything); a deterministic order keeps outputs reproducible.

No WeakReference

  • Native: .WeakReference exists; its value becomes .nil once the referent is collected.
  • RVM: there is no such class (97.1 on .WeakReference~new), and .environment has no WEAKREFERENCE entry.
  • Hosts: both. Status: accepted (rule WEAKREF). Reason: without its own collector the RVM could only offer a reference that never empties; the programs that use one (loop while ref~value \= .nil, generating garbage) would then hang instead of failing at once. Host weak references were rejected: they are not deterministic and the RVM retains the objects anyway. Should one be needed, the way is a deterministic marking done on ~value, only in programs that create a WeakReference (roots: the stacks and variables of every activation and activity, the registers of suspended ones, pending messages, .local, .environment, classes and packages; ~subclasses and the requires cache as weak).

Streams, queues and commands

The macrospace is the process's

  • Native: the macrospace is rxapi's, system wide.
  • RVM: the process's, passed to the commands it starts by a file (RVM_MACROSPACE, in the SysSaveRexxMacroSpace format): the child loads it at start and, if it changed it, the parent reloads it when the command returns. Same limits as the queues.
  • Hosts: both. Status: accepted. Reason: there is no daemon to hold it; the queues travel the same way (queues).

Queues shared with commands through a file

  • Native: session and named queues live in the rxapi daemon, shared live by every process of the user.
  • RVM: queues are the process's. A command sees them through a file (RVM_QUEUES) and the RVM's own rxqueue placed first in the command's PATH (in RVM.CommandHost~run, ../RVM.Host.cls; ../js/host-node.mjs); what the command leaves there is read back when it ends. Consequences: sharing only with what the RVM starts, and between commands, not live (two concurrent RVMs in a pipeline: the last one wins; a waiting LINEIN does not see what another process adds until the command ends); rxqueue's arguments are the words of its argument string ('a b' is two); a native rexx started by the RVM does not see the queues (queue 'x'; 'rexx -e "say queued()"' shows 1 natively, 0 in the RVM).
  • Hosts: both (JS under Node). Status: accepted. Reason: the RVM has no daemon, so it needs nothing installed and behaves the same in both hosts and the browser; talking to rxapi instead would tie the RVM to the native daemon and its protocol (13).

No rxapi; RXFUNCADD registrations end with the process

  • Native: RXFUNCADD registrations live in rxapi and survive the process: another process sees them with RXFUNCQUERY (and cannot drop them).
  • RVM: registrations are the process's. An RVM library loads (0 when it has the routine); any other module is a classic library the RVM cannot load: the name is registered (RXFUNCQUERY 0, as many RXFUNCDROP as registrations) and calling it is 43.1, as native.
  • Hosts: both. Status: accepted (rule RXAPI). Reason: the RVM is a self-contained process; there is no daemon to start.

A second stream on a redirected standard input

  • Native: a new Stream object for STDIN (.stream~new('STDIN')) when standard input is a file believes it is at position 1 but reads where the descriptor is: after what .INPUT has read ahead (4096 bytes), usually nothing, while its CHARS and LINES count from position 1; a LINES or a positioned read moves the descriptor that the other stream objects read from.
  • RVM: it reads the file from the start (its position is the file's).
  • Hosts: both. Status: accepted. Reason: two stream objects reading one descriptor is undefined behaviour, like using a file through the stream functions and a Stream object at once: what native gives depends on its read-ahead blocks, and no program can rely on it.

A positioned write on a redirected standard output in JS

  • Native: a positioned CHAROUT/LINEOUT (or SEEK) on a standard output or error redirected to a file moves the descriptor's offset, so a command run afterwards writes there.
  • RVM: the JS host moves it for the program's own writes (SAY, the functions, the other standard stream when it is the same file), which go there with pwrite; a command still writes where the descriptor was (StdFile in ../js/hostfile-node.mjs). On a file opened to append both agree: every write goes to the end. The ooRexx host is native's.
  • Hosts: JS. Status: accepted. Reason: Node has no lseek; the offset is read from /proc/self/fdinfo (Linux), but cannot be set.

OPEN BINARY without RECLENGTH on an empty file

  • Native: STREAM(f,'C','OPEN BINARY') on an empty file raises 93 (with no secondary message) and leaves the stream READY with zero-length records; the next LINEOUT kills the interpreter (SIGFPE).
  • RVM: the same error, but the stream is closed again (UNKNOWN).
  • Hosts: both. Status: accepted. Reason: the RVM does not emulate the native crash.

Input for a command is read before it runs

  • Native: ADDRESS ... WITH INPUT feeds the command while it runs, a line at a time, as the command reads; what the command does not read is never asked for. A command that ends without reading leaves an INPUT USING object's LINEIN uncalled, and an error it would raise never happens.
  • RVM: the whole input is gathered before the command starts (input~bytes), so that LINEIN runs and its error goes up (SYNTAX). The two agree whenever the command reads all its input, as every Unix filter does; they differ for one that does not, such as cmd.exe running a program it does not know (with-obj-instream on Windows: native says no error, the RVM SYNTAX 42.3).
  • Hosts: both. Status: pending decision (see below).

QUERY HANDLE in JS

  • Native: the C descriptor (e.g. 5 for the first file).
  • RVM: JS gives Node's descriptor, higher because Node keeps more files open (e.g. 20). The ooRexx host gives the host's. The observable contract (a positive whole number; "" when not open) is the same.
  • Hosts: JS. Status: accepted.

Libraries (P5)

Library coverage

  • rxunixsys is not provided (::REQUIRES 'rxunixsys' LIBRARY is 98.903): it ties a program to Unix, while the RVM is meant to be as portable as ooRexx. Accepted (rule RXUNIXSYS).
  • The named semaphores of REXXUTIL (SysCreateEventSem, SysOpenEventSem, SysCloseEventSem, SysPostEventSem, SysResetEventSem, SysWaitEventSem, SysCreateMutexSem, SysOpenMutexSem, SysCloseMutexSem, SysRequestMutexSem, SysReleaseMutexSem) are not provided: ooRexx deprecates them (rexxref, "Deprecated Rexx features", B.2.1: superseded by the EventSemaphore and MutexSemaphore classes, which the RVM has), because they cannot be implemented reliably on every operating system; the official suite does not test them. Accepted.
  • SysFork, SysWait and SysCreatePipe ("Unix-like systems only" in rexxref) are not provided, for the same reason as rxunixsys: they tie a program to Unix, and a fork has no meaning in the JS host. Accepted.
  • A call to any of them is an ordinary external call (43.1 unless a program file of that name exists); RXFUNCQUERY answers 1 (native 0); see 12.

EXTERNAL methods of a library the RVM lacks

  • Native: ::METHOD m EXTERNAL 'LIBRARY lib entry' of a library that cannot be loaded fails when the package is translated (98.903).
  • RVM: for an ooRexx library with methods that the RVM does not implement (orxncurses, oodialog...), the package loads and its other methods work; the method raises 98.903 when it runs (CallNative / callNative, key L). Every other EXTERNAL error is raised before the first clause, as natively (12).
  • Hosts: both. Status: accepted. Reason: a package that wraps such a library can still be loaded and its other methods used.

rxsock in the JS host

The JS host emulates the kernel's sockets on Node (../js/sockets-worker.mjs):

  • descriptors start at 3 (native: 5, since it has 3 and 4 open);
  • a bound stream socket is already listening (Node binds and listens at once);
  • a SockSend never waits (Node buffers without limit);
  • servers always have SO_REUSEADDR;
  • names come from /etc/hosts, then DNS (no aliases outside /etc/hosts).

In the browser there are no sockets (98.903). In both hosts a socket call that would block parks only its activity (as a native thread would), and pending socket I/O is waited for in real time even under the virtual clock. Hosts: JS. Status: accepted (consequences of the platform).

rxmath precision

  • JS: sin, exp, log... come from V8's Math, which differs from glibc in the last bit for some arguments: visible only at precision 16, as a last-digit difference (a few per cent of a sample of RxCalcExp, RxCalcLog, RxCalcSin results). The ooRexx host calls the host's rxmath and is exact. Status: accepted.
  • Native: a dangling link gets the stat data left by the previous directory entry (readdir counts . and ..), or uninitialized data when there is none: it may show as a directory and be missing from an F (files) search, and its date, size and attributes vary from run to run (9999999999 --wxrwxrwx has been seen).
  • RVM: the ooRexx host gives native's lines (it calls the host); JS lists the link as a file with size 0, attributes ---------- and time 0 (what native shows when the data it reuses happens to be zero).
  • Hosts: JS. Status: accepted. Reason: native reads data that stat did not write; there is no behaviour to reproduce.

Programs compiled with rexxc

  • Native: rexxc writes the interpreter's image of the translated program (flattened objects, depending on platform and bitness) after a /**/@REXX header (base64 with -e); rexx, Method~newFile and Routine~newFile/new load it.
  • RVM: reads it as source: 13.1 on the @. Tests that run rexxc and rexx as commands work (they are native).
  • Hosts: both. Status: accepted (rule REXXC). Reason: reading the image means reimplementing ooRexx's image restore. An RVM rexxc wrapping R-code was rejected: it would also need an RVM rexx first in PATH.

.RexxInfo~executable

  • Native: the rexx binary.
  • RVM: the launcher the RVM was started with (rvm, js/rvm: the RVM_EXECUTABLE variable the launchers set), so that programs a program starts (e.g. the test framework's execRexxPrg) run on the RVM too.
  • Hosts: both. Status: accepted (rule EXECUTABLE).

Resource limits

Activation depth

  • Native: about 22,500 nested calls (bounded by its C stack): 11.1.
  • RVM: 10,000 activations per activity: 11.1 (RVM.Machine~maxDepth, JS MAX_DEPTH in ../js/machine.mjs).
  • Hosts: both. Status: accepted. Reason: a fixed, host-independent limit; the frames are the RVM's own, not the host's stack.

Speed of the ooRexx host

  • ooRexx host: about 10 times slower than the JS host and about 1,000 times slower than native on call-heavy code; a test making about a million sends (test_sortWith_bug1466: SORTWITH of 70,000 items) does not finish within the census timeout there, while the JS host runs it in about a minute. Around 40 % of the time is the host's garbage collector (a full mark of a large heap); the rest is spread interpretation with no hot spot.
  • Status: accepted. Reason: the JS host is the fast one; pre-growing the host heap ("ballast") gains a third at the cost of memory and start-up and was not adopted.

Open: pending decision

These are differences kept as the RVM's behaviour until the owner decides whether each becomes an accepted divergence or is fixed.

  • Input for a command is read before it runs: the RVM gathers the input first because a command runs as one host call (a file given as its standard input); feeding it lazily would need a writer running alongside the command.

Native defects not emulated

Where native ooRexx crashes, hangs or gives a result that contradicts its own documentation, the RVM does the documented thing; those defects are tracked outside this documentation. The ones visible to a correct program:

  • XRANGE('digit', '8'): native returns only the range from '8'; the RVM returns the class followed by the range, as documented.
  • DATE(, 0, 'D'): native makes a "month 0" date; the RVM raises 40.19.
  • OPEN BINARY without RECLENGTH (above).

Native defects kept

Some native behaviours that look like defects are what programs and the official test suite see, so the RVM does the same (P1):

  • The errors of the built-in functions are those of what ooRexx runs. Native runs most string functions as methods of String (BuiltinFunctions.cpp: SUBSTR is string->substr(n, length, pad)): the function checks its own arguments first, in their order (the count, 40.3/40.4; an omitted required one, 40.5; a whole number, 40.12; a pad, 40.23), and then the method checks them with its errors (93.9xx, in the method's order), which speak of a method and number the arguments as the method's (INSERT('a','b',-1) is 93.906 "Method argument 2"). So SUBSTR('abc',0) is 93.924, B2X('12') 93.934, DATATYPE('a','Q') 93.915, ABS('x') 93.943, and TRUNC('a','b') 40.12 (argument 2 is the function's, argument 1 the method's). The stream functions send the stream its method (93.907, 93.914, 93.958, 93.0, 88.907 for a count), BEEP, FILESPEC and DIRECTORY are native routines (88.901, 88.907, 88.922), TRACE('Z') is 24.1 as the instruction, an unknown option of ARG, CONDITION, FILESPEC, GC, LINES or STREAM is 40.904, and VALUE's unknown selector 40.914. Mechanism: CallBIF in ../RVM.BIFs.cls and callBIF in ../js/bifs.mjs (11).
  • A security manager set with setSecurityManager while a program runs affects LOCAL and ENVIRONMENT checks at once but other events only in activations created afterwards, because an activation copies its package's manager when it starts (08).

ooTest acceptance rules

The census of the official ooRexx test suite (16) counts apart the failures that are accepted divergences, so that the remaining failures are the RVM's to fix. A failure is accepted only if it matches a rule; each rule is narrow enough that a real regression of the same kind still shows.

Rule What it accepts Divergence
REXXINTEGER every failure of the group base/class/RexxInteger, which tells a RexxInteger from a NumberString by the unrounded MIN MIN and MAX
STRID the IdentityTable tests that depend on string identity (TEST_ALLINDEXES, TEST_ALLITEMS, TEST_AT01, TEST_HASINDEX, TEST_HASITEM, TEST_INDEX, TEST_ITEMS, TEST_MAKEARRAY, TEST_PUT, TEST_REMOVE, TEST_REMOVEITEM, TEST_XOR, TEST_[], TEST_[]=) IdentityTable
WEAKREF 97.1 'Object ".WEAKREFERENCE" does not understand message "NEW"', and the failure ".environment should contain WEAKREFERENCE" No WeakReference
REXXC 13.1 on "@" in a test whose body runs rexxc rexxc
RXUNIXSYS every failure of the rxunixsys groups, and 43.1 for SysStat, SysSymlink, SysGetuid, SysGetgid, SysGetpid or SysUname in other groups (tests that use them as tools: SysStat to build SysFileTree's expected lines, SysSymlink for tilde expansion) Library coverage
EXECUTABLE TEST_REXXINFO_EXECUTABLE failing because the name is not rexx or rexx-oorexx RexxInfo executable
RXAPI TEST_RXAPI_LOCKED of utilities/rxapi (it runs the rxapi next to the executable and expects its "locked" lines) No rxapi

SysFileTree's own output, which the RXUNIXSYS-accepted tests would check, is verified against native by the RVM's own end-to-end cases instead.

Design notes

  • A divergence is either a decision or a debt. Accepted entries have a reason that outweighs compatibility (determinism, portability, no daemon, no own collector, no crash); open entries are differences nobody chose; pending entries wait for that choice. Keeping them apart lets the census report the RVM's real failures.
  • Native wins even against the standard (P1), the errors of the built-in functions included, because an oracle that is wrong in known places is still more useful than none.
  • Determinism over fidelity to timing. Scheduling order, the virtual clock, UNINIT at the end in creation order and the depth limit all trade native's machine-dependent behaviour for runs that are identical on both hosts and every time, which is what makes differential testing against the oracle possible.
  • Per-process state instead of a daemon. Queues, macrospace and RXFUNCADD registrations stay in the process and travel to commands through files; the RVM thus needs nothing installed, at the price of no live sharing between unrelated processes.
  • Maintenance. A change that creates, accepts or fixes a divergence updates this chapter in the same commit; a fixed one is removed (its behaviour is then simply native's). An accepted one that the official suite notices gets a narrow census rule.

Known gaps

Open divergences of this chapter (also in 18-known-gaps.md):

  • Nested waits that cross (93.900).