[En-Nut-Discussion] Race condition and stack overflow in tcpsm.c

Harald Kipp harald.kipp at egnite.de
Wed Nov 19 14:54:11 CET 2014

Hi Philipp,

On 14.11.2014 10:33, Philipp Burch wrote:
> +#include <sys/mutex.h>

I agree that the problem exists, but I do not agree with the way you
tried to fix this.

MUTEX is application candy, which means, that it is possibly used by
some existing code, but not in the kernel. Your change would add quite
some extra bytes for the rest by creating a reference to nut/os/mutex.c.


While Nut/OS is cooperative, mutual exclusion can be done with much less

int NutTcpInitStateMachine(void)
 static int_fast8_t initialized;
 if (!initialized) {
  initialized = 1;
  Code for initialization
 return whatever;



More information about the En-Nut-Discussion mailing list