Bug 84931 - hppa can't handle SIGRTMIN+29
Summary: hppa can't handle SIGRTMIN+29
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-12 09:56 UTC by Pacho Ramos
Modified: 2018-03-19 22:31 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Pacho Ramos 2014-10-12 09:56:31 UTC
Hello

Long time ago the following test failure was reported downstream to:
https://bugs.gentoo.org/show_bug.cgi?id=482214

It affects to HPPA but, as our main hppa developer thinks systemd upstream wouldn't be too cooperative to fix this, he still didn't report it (even if the issue still occurs with newer versions):
$ /bin/systemd --test
Assertion 'sigaddset(ss, sig) == 0' failed at /var/tmp/portage/sys-apps/systemd-206-r3/work/systemd-206/src/shared/util.c:2516, function sigset_add_many(). Aborting.
Aborted

The following information could help you to try to find the problem:
"I'm pretty sure the problem arises in src/core/manager.c:411

#include <stdio.h>
#include <signal.h>

int main( int argc,char * argv )
{
        printf("%d\n", SIGRTMIN);
}

 # ./SIGRTMIN
39

systemd is adding SIGRTMIN+29 (which is well over SIGRTMAX) and isn't checking that properly[1].


[1] signal(7): "include suitable (run-time) checks that SIGRT‐MIN+n does not
    exceed SIGRTMAX"

On PARISC, we have:

#define SIGXCPU         33
#define SIGXFSZ         34
#define SIGSTKFLT       36

and it has been like this since the initial Linux port, it seems. I can't find historical information on this choice.

37 is the first available real-time signal, to which glibc adds another 2 for NPTL, so 39 is the first available signal.
"

Not sure if you would know how to handle this :/

Thanks a lot
Comment 1 Lennart Poettering 2014-10-24 00:06:11 UTC
Hmm, did I get this right? SIGRTMAX-SIGRTMIN is different for Linux on hppa than for Linux on all other archs?

Yuck, what a fuck-up. 

The only sane solution I see is adding a patch that #ifdefs out the code that binds to the high SIGRTMIN+n signals.

What's the last SIGRTMIN+n that works on hppa? Or in other words, what is SIGRTMAX-SIGRTMIN? If you let me know we'll just skip all signal assignments beyond this value on #ifdef __hppa__

Note that the signals we expose are kinda API, hence we cannot dynamically assign them. Hence checking things against SIGRTMAX and shifting things around is really not a good idea. And normally this wouldn't be a problem as on Linux/glibc the number of rt sigs should be stable and fixed. Apparently though with the exception of Linux/hppa...
Comment 2 Mike Gilbert 2014-10-24 01:05:24 UTC
(In reply to Lennart Poettering from comment #1)
> Hmm, did I get this right? SIGRTMAX-SIGRTMIN is different for Linux on hppa
> than for Linux on all other archs?

Yes.

> What's the last SIGRTMIN+n that works on hppa? Or in other words, what is
> SIGRTMAX-SIGRTMIN? If you let me know we'll just skip all signal assignments
> beyond this value on #ifdef __hppa__

From the Gentoo bug that Pacho linked, it seems that SIGRTMIN is 39 on hppa. I assume SIGRTMAX is still 64, so that would make the difference 25.

> Note that the signals we expose are kinda API, hence we cannot dynamically
> assign them. Hence checking things against SIGRTMAX and shifting things
> around is really not a good idea. And normally this wouldn't be a problem as
> on Linux/glibc the number of rt sigs should be stable and fixed. Apparently
> though with the exception of Linux/hppa...

You are probably familiar, but signal(7) says:

"... programs  should never refer to real-time signals using hard-coded numbers, but instead should always refer to real-time signals using  the  notation  SIGRTMIN+n, and include suitable (run-time) checks that SIGRTMIN+n does not exceed SIGRTMAX."

Ideally, systemd would just use a smaller range of signals, without gaps.
Comment 3 Mike Gilbert 2014-10-24 01:21:04 UTC
I also understand that shifting the signals around at this stage in development is not a very nice idea.

However, you could shift them fairly safely whenever SIGRTMAX - SIGRTMIN < 29, since any such system is currently unusable anyway. I suppose that might be a bit difficult since SIGRTMIN is not a constant.
Comment 4 Lennart Poettering 2014-10-24 09:55:07 UTC
(In reply to Mike Gilbert from comment #2)
> (In reply to Lennart Poettering from comment #1)
> > Hmm, did I get this right? SIGRTMAX-SIGRTMIN is different for Linux on hppa
> > than for Linux on all other archs?
> 
> Yes.
> 
> > What's the last SIGRTMIN+n that works on hppa? Or in other words, what is
> > SIGRTMAX-SIGRTMIN? If you let me know we'll just skip all signal assignments
> > beyond this value on #ifdef __hppa__
> 
> From the Gentoo bug that Pacho linked, it seems that SIGRTMIN is 39 on hppa.
> I assume SIGRTMAX is still 64, so that would make the difference 25.

ok, will ifdef out all the signals beyond SIGRTMIN+25 then.

> > Note that the signals we expose are kinda API, hence we cannot dynamically
> > assign them. Hence checking things against SIGRTMAX and shifting things
> > around is really not a good idea. And normally this wouldn't be a problem as
> > on Linux/glibc the number of rt sigs should be stable and fixed. Apparently
> > though with the exception of Linux/hppa...
> 
> You are probably familiar, but signal(7) says:
> 
> "... programs  should never refer to real-time signals using hard-coded
> numbers, but instead should always refer to real-time signals using  the 
> notation  SIGRTMIN+n, and include suitable (run-time) checks that SIGRTMIN+n
> does not exceed SIGRTMAX."
> 
> Ideally, systemd would just use a smaller range of signals, without gaps.

Well, this is supposed to be a fallback interface, in case only "kill" is available. It's a safety net for the admin, not more than that. As such, it matters that the assigned signals are not dynamic, but fixed and documented. Now, I assumed that Linux would always have the same SIGRTMAX-SIGRTMIN, apparently I was wrong.

This isn't too bad though, we can just ifdeff out the upper ones, the safety net is then gone on hppa, but given how exotic that platform is it shouldn't really matter.
Comment 5 Lennart Poettering 2014-10-24 09:56:14 UTC
(In reply to Mike Gilbert from comment #3)
> I also understand that shifting the signals around at this stage in
> development is not a very nice idea.

It's a documented user interface. I really have no intention to break this for an exotic platform like hppa. Especially as the interface is not really that important (see earlier comment).
Comment 6 Lennart Poettering 2014-10-24 11:47:54 UTC
OK, commited this fix now:

http://cgit.freedesktop.org/systemd/systemd/commit/?id=4dffec1459f50ac9f8f67ccfcb79836b4ed5a50e

This should fix builds on hppa. Of course the signals won't be available on hppa then, but I think that's OK.

Please verify that things run on hppa now, as I can't test this. Thanks!
Comment 7 Pacho Ramos 2014-10-24 11:59:18 UTC
Thanks a lot for your help on this :)
Comment 8 Mike Gilbert 2014-10-30 20:09:10 UTC
Sorry to reopen this again; our hppa guy just pointed us at some recent kernel list traffic which proposes lowering SIGRTMIN on parisc (hppa), which would bring it in line with the other architectures.

http://permalink.gmane.org/gmane.linux.ports.parisc/6172
http://permalink.gmane.org/gmane.linux.ports.parisc/6174

Definitely something to keep an eye on, and raises a good question: do you want to revert 4dffec1459f50ac9f8f67ccfcb79836b4ed5a50e, or try to do runtime detection?

In any case, it should probably wait until the patch lands in Linus' tree.
Comment 9 Lennart Poettering 2014-10-31 12:09:21 UTC
Hmm, are you sure they can make that change in the kernel without breaking userspace ABI? I have my doubts there... The number is exported to userspace after all, and many people specify the numeric value on "kill" command lines and such. 

Anyway, let's revert the systemd patch as soon as we know the kernel got changed accordingly. But until then, let's leave the change I made in.
Comment 10 Paolo 2015-02-09 08:11:16 UTC
Sorry... set as NEW by mistake... please set it back to REOPENED. Sorry again!
Comment 11 Lennart Poettering 2018-03-19 22:31:12 UTC
Fixed by https://github.com/systemd/systemd/pull/8408


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.