This may not be the solution to your stack corruption but there is another problem in that code.
All of your strings you are sending over the serial line are declared to be 8 characters and you transmit 8 characters but the strings are only 6 characters (7 if you count the null at the end).
You allocations are OK but the "receiver" may not like either the NULL character or the fact that after the first 7 characters, the 8th character is junk (leftover from the stack's previous use).
in this code:
char data1[8] = "___id:";
int size1 = 8;
ser.write(data1,size1);
data[0] = '_';
data[1] = '_';
data[2] = '_';
data[3] = 'i';
data[4] = 'd';
data[5] = ';';
data[6] = '\0'; (null)
data[7] = (unitialized / leftover junk character)
and you blindly send 8 characters out the serial port. I can't tell you what the right thing to do is or how to re-write your code because I do not know what the other "program / device" reading the data on the serial line is expecting but I'm willing to bet that it's not expecting "junk".