I am very new to the FreeBSD world and am currently porting my terminal emulation library from Linux to FreeBSD and Mac OS. I've encountered some very strange behavior that I've not seen before. Basically, I have some code that does this:
When I inspect the value of 'x' in routineA() it will be a positive number (as it should be). However, the value of 'x' in routineB() is always zero. This does not happen when I build the code on Linux or Mac OS. It also does not matter whether I compile with gcc or clang on FreeBSD. I've exhausted all of the my normal debugging procedures and am considering some more obscure possibilities like stack smashing. However, when I look at ulimit the stack size is set to 524288 and on Linux it is 8192 (so that seems an unlikely culprit). Has anyone encountered something like this on FreeBSD. I'm using FreeBSD version 12.0 fwiw.
C:
void routineA(obj *myobject)
{
printf("%d", myobject->x);
routineB(myobject);
}
void routineB(obj *myobject)
{
printf("%d", myobject->x);
}
When I inspect the value of 'x' in routineA() it will be a positive number (as it should be). However, the value of 'x' in routineB() is always zero. This does not happen when I build the code on Linux or Mac OS. It also does not matter whether I compile with gcc or clang on FreeBSD. I've exhausted all of the my normal debugging procedures and am considering some more obscure possibilities like stack smashing. However, when I look at ulimit the stack size is set to 524288 and on Linux it is 8192 (so that seems an unlikely culprit). Has anyone encountered something like this on FreeBSD. I'm using FreeBSD version 12.0 fwiw.