Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forbid hook routines raising exceptions #1236

Merged
merged 14 commits into from
Mar 16, 2024

Commits on Mar 12, 2024

  1. specify that hooks must not raise exceptions

    The beginning of a language specification test category dedicated to
    hooks is added. At the moment, only the exception-effect-related
    behaviour is covered.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    c4b6fb3 View commit details
    Browse the repository at this point in the history
  2. sempass2: ensure that hooks don't raise exceptions

    The procedure symbol is also marked with the `sfNeverRaises` flag, so
    that defects are prevented from escaping at run-time (they're not
    tracked at compile-time).
    
    A new report is added: `rsemHooksCannotRaise`.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    3e52eaa View commit details
    Browse the repository at this point in the history
  3. liftdestructors: remove "raises" tracking

    Lifting/synthesizing hooks no longer needs to track whether an
    exception is possible.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    65adcae View commit details
    Browse the repository at this point in the history
  4. injectdestructors: always use unchecked calls for hooks

    They're guaranteed to not require exception propagation, so a normal
    `mnkCall` can always be used.
    
    The comment detailing the now-resolved problem with hooks that raise is
    also removed.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    7786e11 View commit details
    Browse the repository at this point in the history
  5. mirgen: implement "never raises" handling

    If a procedure is flagged with `sfNeverRaises`, the body is wrapped in
    a catch-all exception handler, where the new `nimUnhandledException`
    runtime procedure is invoked from the handler. If the handler is not
    actually used, `cgirgen`'s unreachable code elimination automatically
    eliminates it again.
    
    Implementing this in `mirgen` ensures consistent behaviour across all
    backends.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    e493a2a View commit details
    Browse the repository at this point in the history
  6. implement nimUnhandledException for C and JavaScript

    For the VM, it's not as simple as for the other two, so the
    implementation is still missing.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    8110d6a View commit details
    Browse the repository at this point in the history
  7. orc: GC_fullCollect doesn't raise

    The trace hooks were considered to be able to raise exceptions and have
    effects, but this is no longer the case, so the pointer can be safely
    cast to procedural values without.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    e8a94e7 View commit details
    Browse the repository at this point in the history
  8. tasks: mark destroy callback as not raising

    The callback is only used internally, so this does not constitute a
    breaking change of the `Task` API.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    6482de5 View commit details
    Browse the repository at this point in the history
  9. tests: adjust tests

    Three individual tests need to be adjusted to the language change:
    * `tnew` and `gctest use `debugEcho` instead of `write` (the former
      has no effects)
    * `tarcmisc` has to cast away the raise effects of `Stream.close` for
      now
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    0cb2a24 View commit details
    Browse the repository at this point in the history
  10. tests: update --expandArc-using tests

    Hooks not being considered as potentially raising is visible in the
    pretty-printed MIR output.
    zerbina committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    9b22cf4 View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2024

  1. tests: fix specification tests for JS

    Reporting of unhandled exceptions doesn't include a trailing ':' in the
    displayed message if there's no exception message. A message is now set
    on the raised defect, which, besides resulting in consistent output,
    also helps makes sure that the correct defect is reported.
    zerbina committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    4725095 View commit details
    Browse the repository at this point in the history
  2. implement nimUnhandledException for the VM

    The procedure is implemented as a syscall (`vmops`), which raises the
    existing `vmEvtUnhandledException` VM event, thus terminating the VM
    right away.
    
    Since syscall implementations are currently unable to create a stack-
    trace, no stack-trace is passed along, which
    `compilerbridge.buildError` now accounts for (by creating the stack-
    trace itself). This is somewhat hack-y.
    zerbina committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    ef88fcc View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    dd4db85 View commit details
    Browse the repository at this point in the history
  4. jssys: properly terminate when using node.js

    While not possible directly with JavaScript, node.js provides
    `process.exit`, which allows terminating in case of an unhandled
    exception.
    zerbina committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    0643d4d View commit details
    Browse the repository at this point in the history