9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Skip Tavakkolian <skip.tavakkolian@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] syscall silently kill processes
Date: Fri, 17 Jun 2022 09:16:47 -0700	[thread overview]
Message-ID: <CAJSxfmLwumOdObQsg3xnT1-qq3Ew1o7VQuoZLq7cTjmy9V=sAA@mail.gmail.com> (raw)
In-Reply-To: <CAJSxfmKHKa1+eUUji2+wdoS2AEuk1ahCs6wYykgCBaZdNn+WXQ@mail.gmail.com>

Thanks to Douglas Adams, I think '42' might be a more obvious magic
number for a clue:

% 8c udpflood.c && 8l -o udpflood udpflood.8 && ./udpflood | grep end | wc -l
     42
% grep 42 /sys/src/libthread/note.c
#define NFN 42

On Fri, Jun 17, 2022 at 9:11 AM Skip Tavakkolian
<skip.tavakkolian@gmail.com> wrote:
>
> it's worth grepping for persistent magic constants:
>
> % grep 33 /sys/src/libthread/*.[ch]
> /sys/src/libthread/note.c:#define NFN 33
>
> On Fri, Jun 17, 2022 at 9:08 AM Skip Tavakkolian
> <skip.tavakkolian@gmail.com> wrote:
> >
> > interesting catch. it seems to be a tunable limit.
> >
> > % grep NFN /sys/src/libthread/note.c
> > #define NFN 33
> > static int (*onnote[NFN])(void*, char*);
> > static int onnotepid[NFN];
> > for(i=0; i<NFN; i++)
> > return i<NFN;
> > for(i=0; i<NFN; i++){
> > if(i==NFN){
> >
> > On Fri, Jun 17, 2022 at 8:08 AM <andrey100100100@gmail.com> wrote:
> > >
> > > В Пт, 17/06/2022 в 08:11 -0600, Jacob Moody пишет:
> > > > On 6/17/22 07:46, Thaddeus Woskowiak wrote:
> > > > > I believe threadnotify() should be called from threadmain() to
> > > > > properly register the handler in the rendez group
> > > >
> > > > This is incorrect, according to thread(2):
> > > >
> > > > "The thread library depends on all procs
> > > > being in the same rendezvous group"
> > >
> > >
> > > From sleep(2):
> > >
> > >     Alarm causes an alarm note (see notify(2)) to be sent to the
> > >     invoking process after the number of milliseconds given by
> > >     the argument.
> > >
> > > Mean to be sent only to the invoking process, NOT to the process group.
> > >
> > > >
> > > > The issue here is that your note handler has to call noted,
> > > > you are returning from the handler without actually resuming the
> > > > program.
> > > > You either need to call noted(NCONT) to resume execution or
> > > > noted(NDFLT)
> > > > to stop execution.
> > > >
> > > > An excerpt from notify(2):
> > > >
> > > > "A notification handler must finish either by exiting the
> > > > program or by calling noted; if the handler returns the
> > > > behavior is undefined and probably erroneous."
> > > >
> > > > So you are indeed observing undefined behavior.
> > > >
> > >
> > > With:
> > >
> > > ------------------------------------
> > > static int
> > > handler_alarm(void *, char *msg)
> > > {
> > >         if(strstr(msg, "alarm")){
> > >                 noted(NCONT);
> > >                 return 1;
> > >         }
> > >
> > >         return 0;
> > > }
> > > ------------------------------------
> > >
> > > result the same:
> > >
> > > cpu% 6.out | grep end | wc -l
> > >      33
> > >
> > >
> > > And noted(NCONT) may be needed, when process recieved many (2 and more)
> > > notes at once.
> > >
> > > May be something wrong  with interrupted an incomplete  system call?
> > >
> > >
> > > >
> > > > Hope this helps,
> > > > moody
> > > >
> > > 
> > > 
> > > Regards,
> > > Andrej
> > > 

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tfa6823048ad90a21-M5b827bf9eba38f893c1f67bb
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

  reply	other threads:[~2022-06-17 16:17 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17  9:37 andrey100100100
2022-06-17 13:46 ` Thaddeus Woskowiak
2022-06-17 14:11   ` Jacob Moody
2022-06-17 14:39     ` Thaddeus Woskowiak
2022-06-17 15:06     ` andrey100100100
2022-06-17 16:08       ` Skip Tavakkolian
2022-06-17 16:11         ` Skip Tavakkolian
2022-06-17 16:16           ` Skip Tavakkolian [this message]
2022-06-17 17:42             ` adr
2022-06-17 16:11       ` Jacob Moody
2022-06-17 18:48         ` andrey100100100
2022-06-17 19:28           ` Jacob Moody
2022-06-17 21:15           ` adr
2022-06-18  6:40             ` andrey100100100
2022-06-18  8:37               ` adr
2022-06-18  9:22                 ` adr
2022-06-18 12:53                   ` Jacob Moody
2022-06-18 22:03                     ` andrey100100100
2022-06-19  5:54                     ` adr
2022-06-19  6:13                       ` Jacob Moody
2022-06-18 22:22                   ` andrey100100100
2022-06-18 16:57                 ` andrey100100100
2022-06-19  2:40                   ` adr
2022-06-19  5:01                     ` adr
2022-06-19  8:52                       ` andrey100100100
2022-06-19 10:32                         ` adr
2022-06-19 11:40                           ` andrey100100100
2022-06-19 12:01                             ` andrey100100100
2022-06-19 15:10                           ` andrey100100100
2022-06-19 16:41                             ` adr
2022-06-19 21:22                               ` andrey100100100
2022-06-19 21:26                                 ` andrey100100100
2022-06-20  4:41                                 ` adr
2022-06-20  5:39                                   ` andrey100100100
2022-06-20  5:59                                   ` adr
2022-06-20 15:56                                     ` andrey100100100
2022-06-20 22:29                                       ` Skip Tavakkolian
2022-06-21  7:07                                         ` andrey100100100
2022-06-21 11:26                                           ` adr
2022-06-21 13:03                                             ` andrey100100100
2022-06-21 13:22                                               ` adr
2022-06-28 15:28                                                 ` adr
2022-06-28 16:43                                                   ` ori
2022-06-28 18:19                                                   ` adr
2022-06-28 18:28                                                     ` adr
2022-06-28 19:09                                                   ` andrey100100100
2022-06-28 19:42                                                     ` adr
2022-06-29 13:14                                                       ` adr
2022-06-21 13:47                                             ` andrey100100100
2022-06-21  7:22                                         ` adr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJSxfmLwumOdObQsg3xnT1-qq3Ew1o7VQuoZLq7cTjmy9V=sAA@mail.gmail.com' \
    --to=skip.tavakkolian@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).