Problem with msgsnd

From: Marc Schneider (Marc_Schneider@ers.com)
Date: Wed Oct 25 2000 - 16:56:34 EST


msgsnd seems to be corrupting memory around the msgbuf pointer.

for example I have the following code:

pMsgBuf = malloc(iPacketLen + 4 + 8);
bzero(pMsgBuf, iPacketLen + 4 + 8);
pMsgBuf += 4; /* Build a guard band */

printf("PMQ:pMsgBuf: %p\n",pMsgBuf);
printf("PMQ:-4: %p\n", *(pMsgBuf-4));

rc = msgsnd(iMsgQueueID, pMsgBuf, iPacketLen, 0);

printf("AMQ:pMsgBuf: %p\n",pMsgBuf);
printf("AMQ:-4: %p\n", *(pMsgBuf-4));

results in the following output:

PMQ:pMsgBuf: 0x8067424
PMQ:-4: (nil)
AMQ:pMsgBuf: 0x8067424
AMQ:-4: 0x3

clearly, AMQ:-4 should print (nil).

Any ideas as to what could be going wrong?

I'm am running a stock Redhat 6.1 system, kernel 2.2.14 I believe.

This is also causing a segmentation fault.

Marc
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 31 2000 - 21:00:17 EST