ESP32 - MGC3130 (Stack smashing protect failure!)

Hi, I am new in using ESP32. I have project that uses ESP32 Dev Module to get xyz coordenates of MGC3130, and I am using this library GitHub - systronix/Skywriter: Arduino library for MGC3130 as used on Skywriter boards but should work with Flick boards too.
I tried this code with the Arduino UNO and it works, but with the ESP32 doesn’t work.

#include <skywriter.h>
#include <Wire.h>

//GPIO 22 (SCL) and GPIO 21 (SDA)
#define PIN_MCLR 4
#define PIN_TS 0
//sudo chmod a+rw /dev/ttyACM0

void setup() {
  Serial.begin(115200);
  while(!Serial){};
  Serial.println("Hello World!");
  Skywriter.begin(PIN_TS, PIN_MCLR);
  Skywriter.onXYZ(handle_xyz);
}

void loop() {
  Skywriter.poll();
}

void handle_xyz(unsigned int x, unsigned int y, unsigned int z){
 char buf[17];
 sprintf(buf, "%05u:%05u:%05u", x, y, z);
 Serial.println(buf);
}

The output is:

Hello World!
00000:00000:00000

Stack smashing protect failure!

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

Backtrace: 0x4008c228:0x3ffb1ea0 0x4008c455:0x3ffb1ec0 0x400d5784:0x3ffb1ee0 0x400d0c31:0x3ffb1f00 0x400d0d31:0x3ffb1f40 0x400d0f06:0x3ffb1f70 0x400d0c82:0x3ffb1f90 0x400d2301:0x3ffb1fb0 0x400889d9:0x3ffb1fd0

Rebooting…
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Hello World!
00000:00000:00000

Stack smashing protect failure!
[…]

Serial.println("Hello World!");
  Skywriter.begin(PIN_TS, PIN_MCLR);

Prints hello world and crashes on the next line.

First looking at PIN_TS and PIN_MCLR, I see the defination

#define PIN_MCLR 4
#define PIN_TS 0

of using GPIO_NUM_4 and GPIO_NUM_0, though why not use the natural i2C pins?

Looking at a schematic, using GPIO_NUM_4 should not a problem but using GPIO_NUM_0 can be. You may notice 2 buttons on the ESP32 module? If you look at the schematic of the ESP32 you will see GPIO_NUM_0 is attached to one of the buttons as well as a 12K pull up resistor and there might lie the issue. Try using another pin. GPIO_NUM_5 or GPIO_NUM_15 are good choices. Well during program load GPIO_NUM_15 state must not change as its the TDO.

If a pin change works good, issue solved. If not start to work on fixing that library.

Thanks,
I already solved. I needed more that 17 bits to “buf”.