mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rabbitstack <rabbitstack7@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: setrlimit hangs the process
Date: Thu, 11 Oct 2018 17:14:59 +0200	[thread overview]
Message-ID: <CAA3hR4cSZvf5P7-jYL+ZHrWX9EBrdpRUi36MaV9p7o1yRKGp5w@mail.gmail.com> (raw)
In-Reply-To: <20181009204003.GK17110@brightrain.aerifal.cx>


[-- Attachment #1.1: Type: text/plain, Size: 2626 bytes --]

Hi

I managed to reproduce the problem with minimal code snippet and can
confirm it's definitely the Go stdlib signal handler that messes things up.
Here's the code:

package main

import (

   bpflib "github.com/iovisor/gobpf/elf"
   "os/signal"
   "os"
   "fmt"
)

func main() {
   sig := make(chan os.Signal)
   signal.Notify(sig, os.Kill, os.Interrupt)

   mod := bpflib.NewModule("/tmp/sched.o")
   fmt.Println("loading ebpf module")
   err := mod.Load(nil)
   if err != nil {
      panic(err)
   }
   err = mod.EnableKprobes(50)
   if err != nil {
      panic(err)
   }
   fmt.Println("loaded ebpf module")
   rxChan := make(chan []byte)
   lostChan := make(chan uint64)

   pmap, err := bpflib.InitPerfMap(
      mod,
      "sched",
      rxChan,
      lostChan,
   )

   if err != nil {
      panic(err)
   }

   go func() {
      for {
         select {
         case pe := <-rxChan:
            fmt.Println(pe)
         case l := <-lostChan:
            fmt.Println(l)
         }
      }
   }()
   pmap.PollStart()
   fmt.Println("listening on ebpf map")
   <-sig
}

The main thread hangs right after the call to module constructor.


On Tue, Oct 9, 2018 at 10:40 PM Rich Felker <dalias@libc.org> wrote:

> On Tue, Oct 09, 2018 at 10:36:41PM +0200, Szabolcs Nagy wrote:
> > * Rabbitstack <rabbitstack7@gmail.com> [2018-10-09 21:37:06 +0200]:
> > >  Should we raise an issue in Go upstream repository since there is
> nothing
> > > actionable from musl side?
> > >
> >
> > have you figured out where the siprocmask came from?
> > it might not be the go runtime but some c lib that you linked in.
>
> Well the sigset_t was created in Go code or via some other code that
> bypasses libc. The libc functions cannot create a sigset_t with the
> implementation-internal signals masked.
>
> > > El vie., 5 oct. 2018 2:47, Rich Felker <dalias@libc.org> escribió:
> > > > >
> > > > > Here is the bug:
> > > > >
> > > > > 6208  rt_sigprocmask(SIG_SETMASK, ~[HUP INT QUIT ILL TRAP ABRT BUS
> FPE
> > > > SEGV TERM STKFLT CHLD PROF SYS RTMIN RT_1],  <unfinished ...>
> >
> > the go runtime should not make this call, it probably comes from
> > somewhere else.
> >
> > i think you should try to create a minimal reproducer go code
> > that makes this syscall.
>
> I looked at the Go implementations of the functions for sigset_t
> manipulation and sigprocmask. They all bypass libc. So either it's an
> error to use them at all in programs that link with libc, or a bug in
> Go that they don't respect SIGRTMIN, etc.
>
> Rich
>

[-- Attachment #1.2: Type: text/html, Size: 5086 bytes --]

[-- Attachment #2: sched.o --]
[-- Type: application/octet-stream, Size: 7560 bytes --]

      reply	other threads:[~2018-10-11 15:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25 12:59 Rabbitstack
2018-09-25 14:15 ` Szabolcs Nagy
2018-09-25 14:54   ` Rabbitstack
2018-09-25 15:13     ` Rich Felker
2018-09-25 15:38       ` Szabolcs Nagy
2018-09-25 15:36     ` Szabolcs Nagy
2018-09-25 16:38       ` Rich Felker
2018-10-04 14:54         ` Rabbitstack
2018-10-04 15:04           ` Rich Felker
2018-10-04 15:41             ` Rabbitstack
2018-10-04 15:53               ` Rich Felker
2018-10-04 16:05                 ` Rabbitstack
2018-10-05  0:47                 ` Rich Felker
2018-10-09 19:37                   ` Rabbitstack
2018-10-09 19:45                     ` Rich Felker
2018-10-09 20:36                     ` Szabolcs Nagy
2018-10-09 20:40                       ` Rich Felker
2018-10-11 15:14                         ` Rabbitstack [this message]

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=CAA3hR4cSZvf5P7-jYL+ZHrWX9EBrdpRUi36MaV9p7o1yRKGp5w@mail.gmail.com \
    --to=rabbitstack7@gmail.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).