Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* netstat issue on Tru64. Kernel bug?
@ 2004-06-07 10:10 Loic Domaigne
  2004-06-07 19:53 ` Brian Haley
  0 siblings, 1 reply; 5+ messages in thread
From: Loic Domaigne @ 2004-06-07 10:10 UTC (permalink / raw)


Hello Everybody, 

Usually (wanabee) programmers claim compiler and OS responsible for
their programs not working properly... But this time, I feel that's
might be really a kernel issue, rather than a broken application.

I posted a summary some times ago on the Tru64 manager mailing list,
but didn't get any answer so far. The experiment below has been
conducted on Tru64 4.0F. I would be interested to know if this netstat
issue persists on newer Tru64 (5.x).

Any comments are appreciated, especially if I fool myselves with the
"example program".


Cheers,
Loic. 

<copy>

Dear Tru64 Managers,

I have noticed that many people were faced to the "netstat hangs"
problem. But I didn't found a clear answer regarding that issue.

I ran two weeks ago in that problem too, and here a summary of my
investigations (on Tru64 4.0F, but this might apply to newer Tru64 as
well, if I refer to the posts on this list).

If a process writes in a message queue in such way that it overflows
the queue (for instance, no receiver presents), then when the maximum
of oustanding messages is reached (40 on my system), netstat hangs.
BTW, not only netstat, but also program like lsof. As soon as the
queue is removed, netstat (resp. lsof) works fine again.

I believe, this is a Tru64 issue? Since, the only process that should
be eventually "punished" is the writer (if IPC_NOWAIT isn't passed to
msgflg, the writer should block). However, even if a message queue has
kernel persistence, I don't believe that other processes like netstat
should block too...

Below, you shall find overflowQ.c, a program that does nothing but
overflow a message queue, as well a description to reproduce the
problem (steps.txt).

You might known all of this already... But I felt it would be perhaps
a good idea to post that summary.


Cheers,
Loic.


------------------ overflowQ.c

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <errno.h>

#define MSGQ_KEY 0x1234
#define PERM     0660

struct mymsg {
 long mtype;
 char mtext[1];
};

int
main()
{
 int            msg_id;  /* message Queue id.            */
 struct mymsg   msg;     /* message to send.             */
 int            nmsg;    /* number of msg send.          */
 int            status;  /* status returned by msgsnd(). */
 /*
  * Create Message Queue
  */
 if ( (msg_id = msgget (MSGQ_KEY, PERM | IPC_CREAT | IPC_EXCL)) == -1
) {
   perror ("msgget: ");
   exit (EXIT_FAILURE);
 }   
 /*
  * now write message one by one until Queue is full
  */  
 msg.mtype    = 1;
 msg.mtext[0] = 'A';
 nmsg         = 0;
 do {
   status = msgsnd (msg_id, &msg, sizeof(msg.mtext), IPC_NOWAIT);
   nmsg++;
   printf ("Sent msg #%d\r", nmsg);
 }
 while ( status == 0 );
 
 if (errno != EAGAIN ) { /* eh? we didn't overflow? */
   perror ("msgsnd: ");
   exit (EXIT_FAILURE);
 }
 
 printf ("Queue full, sent %d messages\n", nmsg-1);
 exit (EXIT_SUCCESS);
}


------------------ steps.txt

===============================
Steps to reproduce the problem:
===============================

bash$ netstat 
Proto Recv-Q Send-Q  Local Address          Foreign Address       
(state)
tcp        0      0  vdphr1.sshd            wks4.33524            
ESTABLISHED
tcp        0      0  localhost.3922         localhost.2301        
TIME_WAIT
tcp        0      0  localhost.3923         localhost.2301        
TIME_WAIT
...

bash$ overflowQ
Queue full, sent 40 messages

bash$ netstat 
[ hangs... ]

bash$ ipcs -qa 
T      ID        KEY    MODE         OWNER    GROUP  CREATOR   CGROUP
CBYTES  QNUM QBYTES LSPID LRPID  STIME    RTIME    CTIME
q       0 0x41003ec7 --rw-------      root   system     root   system 
    0     0  16384     3 13647 14:24:29 14:24:29  8:37:07
q     130     0x1234 --rw-rw----      loic      vdp     loic      vdp 
   40    40  16384 13662     0 14:25:06 no-entry 14:25:06

removing the queue solve the problem:
bash$ ipcrm -q 130 
bash$ netstat 
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address       
(state)
tcp        0      0  vdphr1.sshd            wks4.33524            
ESTABLISHED
tcp        0      0  localhost.3939         localhost.2301        
TIME_WAIT
tcp        0      0  localhost.3940         localhost.2301        
TIME_WAIT
...

Note: there is no need to restart kloadsrv.

</copy>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: netstat issue on Tru64. Kernel bug?
  2004-06-07 10:10 netstat issue on Tru64. Kernel bug? Loic Domaigne
@ 2004-06-07 19:53 ` Brian Haley
  2004-06-08  7:34   ` Loic Domaigne
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Haley @ 2004-06-07 19:53 UTC (permalink / raw)


You need to find the rogue process that is writing messages noone is 
reading (or find why the reader went away), there is no other workaround 
or fix except for increasing the size of the message queues, which just 
delays the problem.

You can maybe get this info using the audit subsystem, here's an example 
I cut/pasted:

   # auditd -o o                                   ; to enable the auditd
   # auditmask -s cmd_name msgget msgsnd msgrcv    ; audit syscalls

After the message queue fills:

   # audit_tool `auditd -dq`            ; view data (note the csh syntax)

Which shows in this case the user with ruid 10 ran msgget_test which
exercised the msgget syscall:

   audit_id:    10            ruid/euid:   10/10
   pid:         656405        ppid: 656382               cttydev: (6,1)
   cmd name:    msgget_test
   event:       msgget
   key:         IPC_PRIVATE
   flag:        0x200 : creat
   id:          0x81
   result:      129 (0x81)
   cpu, seq#:   0x0, 1
   ip address:  xxx.xxx.xxx.xxx (xxxx)
   timestamp:   Mon Nov 24 11:45:02.51 2003 EST

If audit is not supported by your kernel, you can doconfig a new kernel
with DEC_AUDIT or run the "sysman auditconfig".

Manpages are available for each of the above utilities.  A "best 
practices" manual on Debugging with Audit is also available at:
   http://h30097.www3.hp.com/docs/best_practices/BP_AUDIT/TITLE.HTM

Good luck,

-Brian


Loic Domaigne wrote:

> Hello Everybody, 
> 
> Usually (wanabee) programmers claim compiler and OS responsible for
> their programs not working properly... But this time, I feel that's
> might be really a kernel issue, rather than a broken application.
> 
> I posted a summary some times ago on the Tru64 manager mailing list,
> but didn't get any answer so far. The experiment below has been
> conducted on Tru64 4.0F. I would be interested to know if this netstat
> issue persists on newer Tru64 (5.x).
> 
> Any comments are appreciated, especially if I fool myselves with the
> "example program".
> 
> 
> Cheers,
> Loic. 

<snip>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: netstat issue on Tru64. Kernel bug?
  2004-06-07 19:53 ` Brian Haley
@ 2004-06-08  7:34   ` Loic Domaigne
  2004-06-09  1:15     ` Mario Stargard
  0 siblings, 1 reply; 5+ messages in thread
From: Loic Domaigne @ 2004-06-08  7:34 UTC (permalink / raw)


Hi Brian, 

> You need to find the rogue process that is writing messages noone is 
> reading (or find why the reader went away), there is no other workaround 
> or fix except for increasing the size of the message queues, which just 
> delays the problem.

The difficulty wasn't to find the guilty process (missing reader) but
why an application - that had nothing to do with the story - suddently
stopped working properly. This application was using ssh, which in
turned used netstat...

As you might guess, that was a hell of work to sort this out! 


> You can maybe get this info using the audit subsystem, here's an example 
> I cut/pasted:

Yeah, thanks Brian for the info. 
That might be handy on some circumstances!


Although you are not supposed to overflow a message queue, IMHO this
fault should only punish the writer process: when not enough space
available ==> put writer to sleep state until a reader fetch enough
data. Other UNIX behave this way, which I would expect BTW.

Here, with that implementation, other (system-wide!) processes got
punished too (like netstat, lsof, ssh...). Does someone know if this
"Tru64 specific issue" is reported somewhere?


Cheers,
Loic.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: netstat issue on Tru64. Kernel bug?
  2004-06-08  7:34   ` Loic Domaigne
@ 2004-06-09  1:15     ` Mario Stargard
  2004-06-09  9:00       ` Loic Domaigne
  0 siblings, 1 reply; 5+ messages in thread
From: Mario Stargard @ 2004-06-09  1:15 UTC (permalink / raw)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Loic Domaigne wrote:
| Hi Brian,
|
|
|>You need to find the rogue process that is writing messages noone is
|>reading (or find why the reader went away), there is no other workaround
|>or fix except for increasing the size of the message queues, which just
|>delays the problem.
|
|
| The difficulty wasn't to find the guilty process (missing reader) but
| why an application - that had nothing to do with the story - suddently
| stopped working properly. This application was using ssh, which in
| turned used netstat...
|
| As you might guess, that was a hell of work to sort this out!
|
|
|
|>You can maybe get this info using the audit subsystem, here's an example
|>I cut/pasted:
|
|
| Yeah, thanks Brian for the info.
| That might be handy on some circumstances!
|
|
| Although you are not supposed to overflow a message queue, IMHO this
| fault should only punish the writer process: when not enough space
| available ==> put writer to sleep state until a reader fetch enough
| data. Other UNIX behave this way, which I would expect BTW.
|
| Here, with that implementation, other (system-wide!) processes got
| punished too (like netstat, lsof, ssh...). Does someone know if this
| "Tru64 specific issue" is reported somewhere?
|
|
| Cheers,
| Loic.

How long did you wait for netstat to return?  I was under the impression
that once the message queue fills, ipc turns to spool files in /var/tmp.
~   This is, of course, three orders of magnitude slower.  This is what
happens in our BEA Tuxedo appserver.

Whether this is fixed somewhere is a matter for the patch documentation.

I have stumbled across a similar bug in the audit subsystem in version
5.  The kernel will refuse to allow new processes to spawn if you kill
the parent auditd without cleaning up the children.  A simple kill -9
will do that.  Don't know if it's related.  I'm just avoiding it.

Cheers,
Mario
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFAxmSiDMt+/gswqTsRAoU5AJ9+KxpBdhJDvgeT62umGlGeSSabogCghsnm
hgv0eIQRYaYFaM8qC2WcBg8=
=p+It
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: netstat issue on Tru64. Kernel bug?
  2004-06-09  1:15     ` Mario Stargard
@ 2004-06-09  9:00       ` Loic Domaigne
  0 siblings, 0 replies; 5+ messages in thread
From: Loic Domaigne @ 2004-06-09  9:00 UTC (permalink / raw)


Hi Mario,

> How long did you wait for netstat to return?  I was under the impression
> that once the message queue fills, ipc turns to spool files in /var/tmp.
> ~   This is, of course, three orders of magnitude slower.  This is what
> happens in our BEA Tuxedo appserver.

I have re-tested today. netstat definitively hangs (after 98 min I
decided to press Ctrl-C. Normally, netstat lasts less than 100ms). I
believe we're far from the 3 order of magnitude...


> Whether this is fixed somewhere is a matter for the patch documentation.

I shall have a look at it. 

 
> I have stumbled across a similar bug in the audit subsystem in version
> 5.  The kernel will refuse to allow new processes to spawn if you kill
> the parent auditd without cleaning up the children.  A simple kill -9
> will do that.  Don't know if it's related.  I'm just avoiding it.

Ok, thanks.


Cheers,
Loic.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-06-09  9:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-07 10:10 netstat issue on Tru64. Kernel bug? Loic Domaigne
2004-06-07 19:53 ` Brian Haley
2004-06-08  7:34   ` Loic Domaigne
2004-06-09  1:15     ` Mario Stargard
2004-06-09  9:00       ` Loic Domaigne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox