tl;dr: The message probably means your function is overwriting its array: A stack overflow is caused by a stack that grows downward into the allocated heap space, either causing damage to data within the heap, or code using that heap space causing damage to the contents of the stack. But "stack smashing" refers to damage caused by function code writing past the bounds of an automatic local variable and damaging the stack contents, typically including the function's return address. [Feel free to skip rather long explanation:] A function's stack-frame begins with the return address - the address following the instruction that calls the function, i.e., the address of the next instruction to be executed after the function returns. Then, building downwards, the call parameters are put on the stack and become local variables. Then any variables allocated during the function execution are allocated, still building downward. Assume one of those allocated variables is an array. Its zero-th element is in the lowest address of the allocated space, and subsequent elements are at successively higher addresses. If I start writing into the array, and continue past its length, I'll eventually overwrite other automatic locals, my parameters, and and my return address. Then, when the function tries to return, instead of jumping to the code that called the function, the MCU uses the damaged return address and jumps to ... ???? To catch this error, the compiler can insert code that 1) allocates and writes a "canary" - a known value - just after the return address, and 2), checks the canary for damage just before the function returns. If the canary has been altered, you get the message you saw, because it's likely that the return address will have been altered also. But regardless, the canary isn't part of your code and isn't accessible to it. Thus, it detects *writing-out-of-bounds errors*. [End of wordy explanation] Check the code in your function 'void vReadingModBus()' - my money is on the loop that writes into `szResposta[]`: char szResposta[N_MAX] = "", szByte[3]; for (i = 0; i < nCmpt; i++) { sprintf(szByte, "%02X", ucSt[i]); strcat(szResposta, szByte); Serial.print(ucSt[i], HEX); Serial.print(" "); } Update: > If I understood correctly, it means szResposta must be overwriting the > function's return address? How should I avoid this? The short answer is make your array big enough for what you're going to put in it. But that's probably not a satisfying answer though, so let's take a closer look. I'm not sure exactly what your intent is in that loop, but since you print the `strcat()` result at every iteration and you don't seem to use `szResposta` after that, perhaps you meant to call `strcpy()` (replace the contents of the array) instead of `strcat()` (extend the contents of the array). If so, `strcat()` would quite likely write past the array bounds.