getenv("USER") returns two different addresses when called from two different functions.
0x7fff60e15e79 0x60e15e79
So in the second case the 7fff part is missing . This is leading to a crash when I try to print the string in the second case . Does anyone has any idea why this might be happening?