Pointer to stack variable passed to pthread_create
Status: Beta
Brought to you by:
kagoldman
PlatformSIgnalService in TcpServerPosix.c passes a pointer to the port number to the PlatformSvcRoutine thread. Unfortunately the pointer is to a stack variable, so the port value isn't typically valid by the time that the PlatformSvcRoutine thread starts.
I don't know why a pointer is passed, vs just passing the port number as an imediate value since it fits within a void pointer. Another fix is defining a static var that holds the port number, which I think is safe because PlatformSignalService appears to be called only through StartTcpServer, which appears to be called only from main in TPMCmds.c.
I hopefully fixed this by stack allocating the variables up at main. I could not reproduce the issue, so I can't be sure.
I inherited some of this code, and I believe that a pointer is the common usage between Windows and Posix.
Last edit: Ken Goldman 2016-04-11