Bug 2383 - [PATCH] Please use sysdeps for selecting linuxthreads internal signals
Summary: [PATCH] Please use sysdeps for selecting linuxthreads internal signals
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: linuxthreads (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: drow@false.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 09:38 UTC by Petr.Salinger
Modified: 2012-03-08 04:37 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2006-04-26 15:41:59


Attachments
proposed patch (1.53 KB, patch)
2006-02-22 09:39 UTC, Petr.Salinger
Details | Diff
PTHREAD_SIGBASE patch (631 bytes, patch)
2006-07-24 14:35 UTC, Daniel Jacobowitz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr.Salinger 2006-02-22 09:38:22 UTC
On GNU/kFreeBSD, there are 128 signals available, but they are non-rt.
Could be possible to move rules for selecting used signals number   
and rt/non-rt behaviour from linuxthreads/pthread.c into sysdeps ?

Thanks in advance

Petr
Comment 1 Petr.Salinger 2006-02-22 09:39:54 UTC
Created attachment 887 [details]
proposed patch
Comment 2 Dwayne Grant McConnell 2006-02-28 21:59:56 UTC
I'm not sure moving declarations from a .c to a .h is good. I would think you
could do this by providing an alternate .c or by using #ifdef in the existing .c.
Comment 3 Daniel Jacobowitz 2006-02-28 22:07:31 UTC
Petr, are there any RT signals?  Is __SIGRTMIN defined?
Comment 4 Petr.Salinger 2006-03-01 06:41:59 UTC
(In reply to comment #3)
> Petr, are there any RT signals?  Is __SIGRTMIN defined?

No, kfreebsd does not define __SIGRTMIN , non-rt variants of pthread_restart(),
pthread_suspend(),  pthread_timedsuspend() are used on kfreebsd. 

All others Linux specifics (like syscalls in linuxthreads/sysdeps/i386/tls.h)
are overrided by kfreebsd specifics sysdeps. 

Petr
 
Comment 5 Daniel Jacobowitz 2006-04-26 15:41:59 UTC
I think I'd want to see how you were replacing the new header on kfreebsd.
Comment 6 Petr.Salinger 2006-04-26 16:03:15 UTC
> I think I'd want to see how you were replacing the new header on kfreebsd.

Our pthread_sig.h is rather simple:

**********************************************
/* Signal numbers used for the communication. */
                                          
int __pthread_sig_restart = 32;
int __pthread_sig_cancel  = 33;
int __pthread_sig_debug   = 34;
**********************************************

Our whole linuxthreads kfreebsd sysdeps are browseable at:
http://svn.debian.org/wsvn/glibc-bsd/trunk/glibc-2.3-head/linuxthreads/kfreebsd/?rev=0&sc=0
They go into  $SRC/linuxthreads/sysdeps/unix/bsd/bsd4.4/kfreebsd

And also our main kfreebsd sysdeps:
http://svn.debian.org/wsvn/glibc-bsd/trunk/glibc-2.3-head/sysdeps/kfreebsd/?rev=0&sc=0
They go into  $SRC/sysdeps/unix/bsd/bsd4.4/kfreebsd

Petr
Comment 7 drow@false.org 2006-04-26 16:46:15 UTC
Subject: Re:  [PATCH] Please use sysdeps for selecting linuxthreads internal signals

On Wed, Apr 26, 2006 at 04:03:15PM -0000, Petr dot Salinger at seznam dot cz wrote:
> **********************************************
> /* Signal numbers used for the communication. */
>                                           
> int __pthread_sig_restart = 32;
> int __pthread_sig_cancel  = 33;
> int __pthread_sig_debug   = 34;
> **********************************************

So... why not define __SIGRTMIN to 32 while building glibc?  Seems like
everything would just work, modulo maybe changes to your allocrtsig.c.

Comment 8 Petr.Salinger 2006-04-26 17:26:56 UTC
> So... why not define __SIGRTMIN to 32 while building glibc?  Seems like
> everything would just work, modulo maybe changes to your allocrtsig.c.

We can't. :-( 

On FreeBSD 5.x and 6.x there are no rt-signals.
So we must not advertise them via __ASSUME_REALTIME_SIGNALS,
otherwise rt variants of pthread_restart(), pthread_suspend(),
pthread_timedsuspend()
will be used (see restart.h) => BAD.

Iff we don't advertise them, init_rtsigs () calls _libc_current_sigrtmin_private ().

Based on result, it will either
 -  use SIGRTMIN & rt-variants   => again BAD
 -  use USR1 & USR2 & non-rt variants => BAD (same collision as with linux 2.0)

Moreover

- it looks like  __SIGRTMIN is also used for advertising whether real-time
signals are available 
- there will be rt-signals in FreeBSD 7.x, but with numbers #65-#126 
 - we must use #32-#34 for __pthread_sig_*, they have special security handling
in kernel, otherwise setuid threaded application breaks.

Proposed patch only moves a few bits into sysdeps to allow us to override it as
needed.
It  does not change behaviour on Linux.

Thanks for  your time.

Petr

From http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/signal.h

****************************
#if __BSD_VISIBLE
#define SIGTHR          32      /* reserved by thread library. */
#define SIGLWP          SIGTHR
#endif

#define SIGRTMIN        65
#define SIGRTMAX        126
*****************************
Comment 9 Daniel Jacobowitz 2006-07-24 14:35:35 UTC
I really don't like putting this initialization into sysdeps.  For one thing,
Linux is not the only supported port.  I think this would break LinuxThreads for
the Hurd, for instance.

So.  You want to set these to 32-34, but don't want those to be marked by
__SIGRTMIN.  How about setting something like the attached?
Comment 10 Daniel Jacobowitz 2006-07-24 14:35:58 UTC
Created attachment 1178 [details]
PTHREAD_SIGBASE patch
Comment 11 Alfred M. Szmidt 2006-07-24 15:02:37 UTC
Subject: Re:  [PATCH] Please use sysdeps for selecting linuxthreads internal signals

   I really don't like putting this initialization into sysdeps.  For
   one thing, Linux is not the only supported port.  I think this
   would break LinuxThreads for the Hurd, for instance.

The Hurd doesn't use LinuxThreads.
Comment 12 drow@false.org 2006-07-24 15:03:41 UTC
Subject: Re:  [PATCH] Please use sysdeps for selecting linuxthreads internal signals

On Mon, Jul 24, 2006 at 03:02:37PM -0000, ams at gnu dot org wrote:
> The Hurd doesn't use LinuxThreads.

Oops, thanks.  Anyway, point stands.

Comment 13 Petr.Salinger 2006-07-24 19:11:15 UTC
(In reply to comment #9)

> So.  You want to set these to 32-34, but don't want those to be marked by
> __SIGRTMIN.  How about setting something like the attached?

It will work for us (together with "#define PTHREAD_SIGBASE 32" in GNU/kFreeBSD 
kernel-features.h).

So, yes, please commit this. It will fully satisfy our needs.
Thanks for your patch.

Petr






Comment 14 Daniel Jacobowitz 2006-07-24 20:09:26 UTC
Checked in.