ClosedCube_HDC1080_Arduino icon indicating copy to clipboard operation
ClosedCube_HDC1080_Arduino copied to clipboard

Stack smashing protect failure when running demo code

Open robert-koetsier opened this issue 3 years ago • 0 comments

I'm using an ESP32 with PlatfromIO, and tried to use this library. When running the hdc1080demo code, I ran into an error. The output looks as follows:

ClosedCube HDC1080 Arduino Test
Manufacturer ID=0x5449
Device ID=0x1050
Device Serial Number=239-461A-FA80

Stack smashing protect failure!


abort() was called at PC 0x400d9258 on core 1

I found that the error was related to this section of the example code:

void printSerialNumber()
{
  Serial.print("Device Serial Number=");
  HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
  char format[12];
  sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
  Serial.println(format);
}

Based on some interaction with chatGPT I found that the issue could be resolved by change the declaration of format to char format[20];.

I have no experience with C++ but I hope this info can help to solve the problem.

robert-koetsier avatar Feb 01 '23 13:02 robert-koetsier