Sponsored Content
Full Discussion: msgrcv crash in AIX 5.3 SP6
Operating Systems AIX msgrcv crash in AIX 5.3 SP6 Post 302201720 by sandhya_chp on Tuesday 3rd of June 2008 02:54:23 AM
Old 06-03-2008
msgrcv crash in AIX 5.3 SP6

Hi All,

I have a piece of code like blow. It is working fine with AIX 5.3 SP3. When the same thing is getting executed in AIX 5. SP6 it is giving segmentation fault. If I put debug statements before and after, it works fine.

rc = msgrcv(mqid, &msg, size, HIGH_PRIORITY_FIRST , 0)
if (rc > 0) {
/* message was recieved (waiting or not) */
memset (buf, NULL, sizeof(MsgBuffer));
memcpy (buf, &msg.message, rc);
}

Can somebody help me what is happening here? Do you think any restriction of message queues is creating the problem.

Thanks,
Sandhya,
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

server crash

Our SUn Solaris Server has crashed second time in 2 days, reason is not known , we are trying to determine what could have gone wrong, any ideas, the power supply seems to be fine, there is no response from keyboard,monitor etc and we had to do a hot boot yesterday.. Any suggestions what could be... (9 Replies)
Discussion started by: knarayan
9 Replies

2. HP-UX

HP-UX system crash help please!!!

Hi, First of all, thanks for your help. I have downloaded freeBSD to study unix I'm here again 'cause my HP-UX 10.x has "broken". It raise this error: ---------------------------------------------------- Diagnostic System warning: = 0x1f005000 is POWERFAILED The diagnostic logging... (1 Reply)
Discussion started by: efrenba
1 Replies

3. Programming

msgrcv pending forever !!!

When I am using msgrcv to get a message from a queue, in case of msgsnd some error, the msgrcv thread will waiting forever. Is there some way that I can specify a time out value for this queue ? just let msgrcv wait for some time, if no message comes during this time slot, msgrcv just return... (3 Replies)
Discussion started by: Yun Gang Chen
3 Replies

4. Solaris

crash dump

Can anyone of you help me in enabling crash dump on Solaris 5.5.1 (1 Reply)
Discussion started by: csreenivas
1 Replies

5. UNIX for Dummies Questions & Answers

msgrcv : Invalid argument

Hi All, Please guide me how to get rid : msgrcv : Invalid argument. I am using message queues: msgsnd and msgrcv, I am able to send through msgsnd and receive through msgrcv, but at times i get the belo error. msgrcv : Invalid argument. (1 Reply)
Discussion started by: answers
1 Replies

6. Solaris

crash dump

hi , i have machine that is crashed how i can enable core dump file & how can i find it ? :confused: (4 Replies)
Discussion started by: lid-j-one
4 Replies

7. Programming

C Posix - msgsnd() msgrcv

Hey guys, Im doing message passing for the first time on a linux OS. Im new to C programming, so bear with me. I made two .c files : central.c and external.c I simply wanted to pass a message from the central process to the external process. BUT Whenever each process gets to the... (3 Replies)
Discussion started by: carl33p
3 Replies

8. UNIX for Dummies Questions & Answers

IPC Message Queue. msgrcv doesnt work..

Hi everybody, this is the situation. there is a programm XYZ which opens a message queue with the key 47110815 and waits for a SIGUSR1. After receiving this signal it sends a message with type 100 and a number (as ASCII) in the message-body. I have to write a prog which frist sends the... (1 Reply)
Discussion started by: daredevil82m
1 Replies

9. AIX

How to restore rootvg archive after AIX 6.1 crash

Hello, Few days ago I created both mksysb and savevg archives of rootvg. How can I restore this rootvg now because the AIX crashed during some software tests. There is no way to start from hdisk0 because most of the system files are deleted (this includes libc.a). I tough it will be trivial... (6 Replies)
Discussion started by: +Yan
6 Replies

10. AIX

Post mortem for critical Production AIX System Reboot/Crash

Hello All, Critical AIX production box crashed/rebooted while our team is working on it and we need to generate a detailed report for that, below are few questions that need to be included in the report. (We are System Administration team and everyone in our team has root access via sudo as well... (3 Replies)
Discussion started by: lovesaikrishna
3 Replies
CMSG_DATA(3)						   BSD Library Functions Manual 					      CMSG_DATA(3)

NAME
CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, CMSG_SPACE -- socket control message routines SYNOPSIS
#include <sys/socket.h> void * CMSG_DATA(struct cmsghdr *); struct cmsghdr * CMSG_FIRSTHDR(struct msghdr *); size_t CMSG_LEN(size_t); struct cmsghdr * CMSG_NXTHDR(struct msghdr *, struct cmsghdr *); size_t CMSG_SPACE(size_t); DESCRIPTION
The control message API is used to construct ancillary data objects for use in control messages sent and received across sockets. Control messages are passed around by the recvmsg(2) and sendmsg(2) system calls. The cmsghdr structure, described in recvmsg(2), is used to specify a chain of control messages. These routines should be used instead of directly accessing the control message header members and data buffers as they ensure that necessary alignment constraints are met. The following routines are provided: CMSG_DATA(cmsg) This routine accesses the data portion of the control message header cmsg. It ensures proper alignment constraints on the beginning of ancillary data are met. CMSG_FIRSTHDR(mhdr) This routine accesses the first control message attached to the message msg. If no control messages are attached to the message, this routine returns NULL. CMSG_LEN(len) This routine determines the size in bytes of a control message, which includes the control message header. len specifies the length of the data held by the control message. This value is what is normally stored in the cmsg_len of each control message. This rou- tine accounts for any alignment constraints on the beginning of ancillary data. This macro might not evaluate to a compile-time con- stant. CMSG_NXTHDR(mhdr, cmsg) This routine returns the location of the control message following cmsg in the message mhdr. If cmsg is the last control message in the chain, this routine returns NULL. CMSG_SPACE(len) This routine determines the size in bytes needed to hold a control message and its contents of length len, which includes the control message header. This value is what is normally stored in msg_msgcontrollen. This routine accounts for any alignment constraints on the beginning of ancillary data as well as any needed to pad the next control message. This macro might not evaluate to a compile- time constant. EXAMPLES
The following example constructs a control message containing a file descriptor and passes it over a socket: struct msghdr msg; struct cmsghdr *cmsg; /* We use a union to make sure hdr is aligned */ union { struct cmsghdr hdr; unsigned char buf[CMSG_SPACE(sizeof(int))]; } *cmsgbuf; /* * We allocate in the heap instead of the stack to avoid C99 * variable stack allocation, which breaks gcc -fstack-protector. */ if ((cmsgbuf = malloc(sizeof(*cmsgbuf))) == NULL) err(1, "malloc"); (void)memset(&msg, 0, sizeof(msg)); msg.msg_control = cmsgbuf->buf; msg.msg_controllen = sizeof(cmsgbuf->buf); cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; *(int *)CMSG_DATA(cmsg) = fd; if (sendmsg(s, &msg, 0) == -1) err(1, "sendmsg"); free(cmsgbuf); And an example that receives and decomposes the control message: struct msghdr msg; struct cmsghdr *cmsg; union { struct cmsghdr hdr; unsigned char buf[CMSG_SPACE(sizeof(int))]; } *cmsgbuf; if ((cmsgbuf = malloc(sizeof(*cmsgbuf))) == NULL) err(1, "malloc"); (void)memset(&msg, 0, sizeof(msg)); msg.msg_control = cmsgbuf->buf; msg.msg_controllen = sizeof(cmsgbuf->buf); if (recvmsg(s, &msg, 0) == -1) err(1, "recvmsg"); if ((msg.msg_flags & (MSG_TRUNC|MSG_CTRUNC)) errx(1, "control message truncated"); for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_len == CMSG_LEN(sizeof(int)) && cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { fd = *(int *)CMSG_DATA(cmsg); /* Do something with the descriptor. */ } } free(cmsgbuf); SEE ALSO
recvmsg(2), sendmsg(2), socket(2) HISTORY
The control message API first appeared in 4.2BSD. BSD
June 20, 2008 BSD
All times are GMT -4. The time now is 12:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy