Skip to content

Misleading error report in case of longjump #953

@lionel-

Description

@lionel-

While reproducing posit-dev/positron#9467 I got:

[R]   2025-10-28T15:41:53.803084Z ERROR  Panic! In file 'crates/ark/src/interface.rs' at line 2422: called `Result::unwrap()` on an `Err` value: Unexpected longjump
[R] Likely caused by:
[R] object 'writeConsole' not found

"Likely caused by" message is totally wrong. It's showing an older error message from earlier.

This is a remnant of our top-level-exec wrapper:

ark/crates/harp/src/exec.rs

Lines 352 to 355 in 5e1d1ad

let mut err_buf = r_peek_error_buffer();
if err_buf.len() > 0 {
err_buf = format!("\nLikely caused by:\n{err_buf}");

It used to be that we didn't catch R errors, so if a longjump was detected it was likely caused by an error, and we would peek into R's buffer to report it to callers. Now that we do catch them, the only errors that could go through there are:

  • Stack overflow errors that can't be caught by our calling condition handler
  • stop() on a condition that doesn't inherit from error

Now that I think of it, we could make both of these more robust by inserting an "abort" restart. Probably not worth it though.

In any case we should now remove that "Likely caused by" addendum since it's now more likely to be misleading.

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