Guru Meditation Error: Core 1 panic'e with free [RESOLVED]

quentho
Posts: 4
Joined: Mon Jun 01, 2020 3:08 pm

Guru Meditation Error: Core 1 panic'e with free [RESOLVED]

Postby quentho » Mon Jun 01, 2020 4:16 pm

Hello ,

I would like to recover the result of my serial2 link. It's a char by char and concatenate them. I use pointers, my code works once when I don't free memory with free() function. When I want to free the memory after use I have directly one problem problems.
I put two pictures one with free, one without.
thank you

Code: Select all

void Wisol::getID()
{
  printf("getID");
  char * data=(char *) malloc(15);
  char * data1=(char *) malloc(15);
  char  receive;

  *(data)='\0';
  //*(data1)='0';
  //*(data1+1)='\0';
  Serial2.begin(9600, SERIAL_8N1, RXPin, TXPin);
  Serial2.println("AT$I=10");
  delay(1000);
  while (Serial2.available()) {
   //Serial.println(char(Serial2.read()));
   delay(100);
   receive= Serial2.read();
   *(data1)=receive;
   printf("data1: %s \n",data1);
   printf("receive: %c \n",receive);
   data=strcat( data, data1 );
   printf("data: %s \n",data);
  }
    //free(data);
  //  free(data1);
}
Attachments
error without free.PNG
error without free.PNG (52.75 KiB) Viewed 2439 times
error with free.PNG
error with free.PNG (60.05 KiB) Viewed 2439 times
Last edited by quentho on Fri Jun 05, 2020 4:03 pm, edited 1 time in total.

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Guru Meditation Error: Core 1 panic'e with free

Postby ESP_Sprite » Wed Jun 03, 2020 8:33 am

You're not making sure data1 is zero-terminated.

Who is online

Users browsing this forum: No registered users and 93 guests