Messages in this thread |  | | Date | Fri, 27 Oct 2000 00:57:01 +0200 | From | "J . A . Magallon" <> | Subject | Re: Problem with msgsnd |
| |
On Thu, 26 Oct 2000 17:15:30 Marc Schneider wrote: > lkml@dm.ultramaster.com wrote: > > > > Marc Schneider wrote: > > > > > > 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)); > > >
Silly question: why do you :
printf("PMQ:-4: %p\n", *(pMsgBuf-4));
instead of: !!! printf("PMQ:-4: %d\n", *(pMsgBuf-4));, or whatever applies...(typeof pMsgBuf?)
If you use %p, printf expects a pointer in stack, and depending on type of pMsgBuf (is a char * ?), *pMsgBuf can be passed as a char (I don't think so, C passes chars as ints, and I dont remenber any kind of option to modify this) or a short or an int...
So, perhaps you dont put enough data on stack for a pointer and printf gets incorrect data (the zero in pMsgBuf plus the return value that stored in rc...).
-- Juan Antonio Magallon Lacarta mailto:jamagallon@able.es
- 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/
|  |