Skip to content

xs OOM behavior fail-stop deterministic by design? #266

Description

@dckc

Is xs fail-stop deterministic on out-of-memory? Is this documented? If so, please point me to it; if not, please document it. (If you just want to confirm that this is by design and let the code serve as the documentation, that works for me.)

@erights asked me about this. Mark, it seems that indeed xs terminates the shared cluster: it seems that c_malloc failures result in gxDefaults.terminateSharedCluster() at https://github.com/Moddable-OpenSource/moddable/blob/public/xs/sources/xsAPI.c#L1428 by way of fxJump(the) .

A little experimentation is consistent with this reading. Using a timeout utility found via a
stackoverflow clue, I ran the js code below under the xs simulator:

~/projects/moddable/examples/js/bug1$ ~/bin/timeout -m 1000000 simulator ~/projects/moddable/build/bin/lin/debug/mc/bug1/mc.so
0
1000
2000
...
23000
MEM CPU 0.49 MEM 1055592 MAXMEM 1055592 STALE 0 MAXMEM_RSS 589536
<time name="ALL">520</time>

No exception was reported.

/* global trace */

export default function main() {
  const space = [];
  let tick = 0;
  try {
    while(tick < 2000000) {
      if (tick % 1000 == 0) {
        trace(`${tick}\n`);
      }
      space.push("nom nom nom MOAR");
      tick += 1;
    }
  } catch (oops) {
    trace(`exception: ${oops}\n`);
  }
  trace(`${tick} - done\n`);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions