While digging through the SerialActiveMessageC stack, I came across the
following in HdlcTranslateC:

  async command error_t SerialFrameComm.putDelimiter() {
    state.sendEscape = 0;
    m_data = HDLC_FLAG_BYTE;
    return call UartStream.send(&m_data, 1);
  }

This allocated a variable on the stack, then passes a pointer to it to
UartStream (PlatformSerialC) and returns. The same construct is used in
putData() and sendDone().

Is this not likely to break if the callee copies the pointer, but
doesn't get to read the data before the stack location is overwritten?
It looks like that could easily happen if an interrupt occurs.

An easy fix would be to allocate a module level, one byte buffer in
HdlcTranslateC and use that to pass the byte, perhaps guarded by a busy
flag.

Regards,
Michiel

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to