Skip to content

vsnprintf with length of 80 chars for format hardfaults the board #92

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

Closed
janjongboom opened this issue Nov 23, 2020 · 4 comments
Closed
Labels
bug Something isn't working nano33ble

Comments

@janjongboom
Copy link
Contributor

This sketch hardfaults the board on v1.3.0 of this Arduino Core on the Arduino Nano 33 BLE Sense:

void printf_wrapper(const char *format, ...) {
    static char print_buf[2048] = { 0 };

    va_list args;
    va_start(args, format);
    int r = vsnprintf(print_buf, 2048, format, args);
    va_end(args);

    if (r > 0) {
        Serial.write(print_buf);
    }
}

void setup() {
  // put your setup code here, to run once:
  delay(5000);
}

void loop() {
  // put your main code here, to run repeatedly:

  printf_wrapper("hello world\n");
  printf_wrapper("hello this is a long text with 40 chars\n");
  printf_wrapper("hello this is a long text with 80 chars hello this is a long text with 80 chars\n");

  delay(1000);

}

This works fine on the 1.1.6 core.

@facchinm
Copy link
Member

Hi Jan,
it looks like #88 already fixes the issue so it may be an mbed problem.
Would you mind testing it?

@janjongboom
Copy link
Contributor Author

@facchinm OK, good to know - we're patching our sketches for now. When do you expect a new core version to come out for this?

@facchinm
Copy link
Member

Just waiting for this PR to be merged ARMmbed/mbed-os#13826 😉

@facchinm facchinm added bug Something isn't working nano33ble labels Dec 2, 2020
@facchinm
Copy link
Member

Fixed by 6c36b42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nano33ble
Projects
None yet
Development

No branches or pull requests

2 participants