Skip to content

Using setjmp/longjmp seems to crash chip #453

@technoblogy

Description

@technoblogy

A program implementing setjmp/longjmp for error recovery seems to have problems opening a serial port. Demonstration:

#include <setjmp.h>

jmp_buf exception;

void error () { Serial.println("Error"); longjmp(exception, 1); }

void setup () {
  Serial.begin(9600);
  Serial.println("Starting");
}

void loop () {
  if (!setjmp(exception)) {}
  Serial.println("Waiting");
  delay(10000);
  error();
}

Hangs up with no port available on arduino-pico core 1.9.15. Works OK on Arduino Mbed OS RP2040 Boards core version 2.6.1.

Test setup:
Raspberry Pi RP2040 board
MacBook Pro with macOS High Sierra 10.13.6
Arduino IDE 1.8.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions