[v4,0/6] Optimize posix_spawn signal setup with clone3

Message ID 20230112135853.3786675-1-adhemerval.zanella@linaro.org
Headers
Series Optimize posix_spawn signal setup with clone3 |

Message

Adhemerval Zanella Netto Jan. 12, 2023, 1:58 p.m. UTC
  Currently posix_spawn has to issue at least NSIG sigaction syscalls
to obtain current signal disposition and more if they there are not
either SIG_IGN or SIG_DFL.  The new clone3 CLONE_CLEAR_SIGHAND flags
introduced with Linux 5.5 resets all signal handlers of the child not
set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this
preparation phase.

The exception is the signals defined by posix_spawnattr_setsigdefault
when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN).  In
this case posix_spawn helper process needs to issue a sigction to
set the signal disposition to SIG_DFL.

The patchset also adds clone3 implementation for aarch64.  The clone3
for x86_64 is change to not align the stack, since this is not
async-signal safe (although current calls does mask/unmask signals).

* Changes from v3:
  - Changes commit message and comments wording.
  - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations.

* Changes from v2:
  - Improve clone3 internal documentation.

* Changes from v1:
  - Extend clone3 documentation.
  - Remove x86_64 stack alignment on clone3 child.
  - Fixed powerpc64 missing initial stack frame.
  - Fixed missing save/restore r7 for arm.

Adhemerval Zanella (6):
  linux: Do not reset signal handler in posix_spawn if it is already
    SIG_DFL
  linux: Extend internal clone3 documentation
  Linux: Do not align the stack for __clone3
  linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
  aarch64: Add the clone3 wrapper
  Linux: optimize clone3 internal usage

 include/clone_internal.h                      |  37 +++-
 posix/Makefile                                |   3 +-
 posix/tst-spawn7.c                            | 179 ++++++++++++++++++
 sysdeps/unix/sysv/linux/Makefile              |   3 +-
 sysdeps/unix/sysv/linux/aarch64/clone3.S      |  85 +++++++++
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |   2 +
 sysdeps/unix/sysv/linux/clone-internal.c      |  59 ++++--
 sysdeps/unix/sysv/linux/clone3.h              |  15 +-
 sysdeps/unix/sysv/linux/kernel-features.h     |   9 +
 sysdeps/unix/sysv/linux/spawni.c              |  33 +++-
 .../sysv/linux/tst-misalign-clone-internal.c  |  74 --------
 sysdeps/unix/sysv/linux/x86_64/clone3.S       |   3 -
 12 files changed, 384 insertions(+), 118 deletions(-)
 create mode 100644 posix/tst-spawn7.c
 create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S
 delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
  

Comments

Adhemerval Zanella Netto Jan. 18, 2023, 5:53 p.m. UTC | #1
Carlos, do we still want this for 2.37?

On 12/01/23 10:58, Adhemerval Zanella wrote:
> Currently posix_spawn has to issue at least NSIG sigaction syscalls
> to obtain current signal disposition and more if they there are not
> either SIG_IGN or SIG_DFL.  The new clone3 CLONE_CLEAR_SIGHAND flags
> introduced with Linux 5.5 resets all signal handlers of the child not
> set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this
> preparation phase.
> 
> The exception is the signals defined by posix_spawnattr_setsigdefault
> when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN).  In
> this case posix_spawn helper process needs to issue a sigction to
> set the signal disposition to SIG_DFL.
> 
> The patchset also adds clone3 implementation for aarch64.  The clone3
> for x86_64 is change to not align the stack, since this is not
> async-signal safe (although current calls does mask/unmask signals).
> 
> * Changes from v3:
>   - Changes commit message and comments wording.
>   - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations.
> 
> * Changes from v2:
>   - Improve clone3 internal documentation.
> 
> * Changes from v1:
>   - Extend clone3 documentation.
>   - Remove x86_64 stack alignment on clone3 child.
>   - Fixed powerpc64 missing initial stack frame.
>   - Fixed missing save/restore r7 for arm.
> 
> Adhemerval Zanella (6):
>   linux: Do not reset signal handler in posix_spawn if it is already
>     SIG_DFL
>   linux: Extend internal clone3 documentation
>   Linux: Do not align the stack for __clone3
>   linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
>   aarch64: Add the clone3 wrapper
>   Linux: optimize clone3 internal usage
> 
>  include/clone_internal.h                      |  37 +++-
>  posix/Makefile                                |   3 +-
>  posix/tst-spawn7.c                            | 179 ++++++++++++++++++
>  sysdeps/unix/sysv/linux/Makefile              |   3 +-
>  sysdeps/unix/sysv/linux/aarch64/clone3.S      |  85 +++++++++
>  sysdeps/unix/sysv/linux/aarch64/sysdep.h      |   2 +
>  sysdeps/unix/sysv/linux/clone-internal.c      |  59 ++++--
>  sysdeps/unix/sysv/linux/clone3.h              |  15 +-
>  sysdeps/unix/sysv/linux/kernel-features.h     |   9 +
>  sysdeps/unix/sysv/linux/spawni.c              |  33 +++-
>  .../sysv/linux/tst-misalign-clone-internal.c  |  74 --------
>  sysdeps/unix/sysv/linux/x86_64/clone3.S       |   3 -
>  12 files changed, 384 insertions(+), 118 deletions(-)
>  create mode 100644 posix/tst-spawn7.c
>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S
>  delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
>
  
Carlos O'Donell Jan. 18, 2023, 10:24 p.m. UTC | #2
On 1/18/23 12:53, Adhemerval Zanella Netto wrote:
> Carlos, do we still want this for 2.37?

I think we should just push this to 2.38.

Start by committing everything we have for x86_64 and aarch64.

Then repost the other arches for review.
 
> On 12/01/23 10:58, Adhemerval Zanella wrote:
>> Currently posix_spawn has to issue at least NSIG sigaction syscalls
>> to obtain current signal disposition and more if they there are not
>> either SIG_IGN or SIG_DFL.  The new clone3 CLONE_CLEAR_SIGHAND flags
>> introduced with Linux 5.5 resets all signal handlers of the child not
>> set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this
>> preparation phase.
>>
>> The exception is the signals defined by posix_spawnattr_setsigdefault
>> when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN).  In
>> this case posix_spawn helper process needs to issue a sigction to
>> set the signal disposition to SIG_DFL.
>>
>> The patchset also adds clone3 implementation for aarch64.  The clone3
>> for x86_64 is change to not align the stack, since this is not
>> async-signal safe (although current calls does mask/unmask signals).
>>
>> * Changes from v3:
>>   - Changes commit message and comments wording.
>>   - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations.
>>
>> * Changes from v2:
>>   - Improve clone3 internal documentation.
>>
>> * Changes from v1:
>>   - Extend clone3 documentation.
>>   - Remove x86_64 stack alignment on clone3 child.
>>   - Fixed powerpc64 missing initial stack frame.
>>   - Fixed missing save/restore r7 for arm.
>>
>> Adhemerval Zanella (6):
>>   linux: Do not reset signal handler in posix_spawn if it is already
>>     SIG_DFL
>>   linux: Extend internal clone3 documentation
>>   Linux: Do not align the stack for __clone3
>>   linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
>>   aarch64: Add the clone3 wrapper
>>   Linux: optimize clone3 internal usage
>>
>>  include/clone_internal.h                      |  37 +++-
>>  posix/Makefile                                |   3 +-
>>  posix/tst-spawn7.c                            | 179 ++++++++++++++++++
>>  sysdeps/unix/sysv/linux/Makefile              |   3 +-
>>  sysdeps/unix/sysv/linux/aarch64/clone3.S      |  85 +++++++++
>>  sysdeps/unix/sysv/linux/aarch64/sysdep.h      |   2 +
>>  sysdeps/unix/sysv/linux/clone-internal.c      |  59 ++++--
>>  sysdeps/unix/sysv/linux/clone3.h              |  15 +-
>>  sysdeps/unix/sysv/linux/kernel-features.h     |   9 +
>>  sysdeps/unix/sysv/linux/spawni.c              |  33 +++-
>>  .../sysv/linux/tst-misalign-clone-internal.c  |  74 --------
>>  sysdeps/unix/sysv/linux/x86_64/clone3.S       |   3 -
>>  12 files changed, 384 insertions(+), 118 deletions(-)
>>  create mode 100644 posix/tst-spawn7.c
>>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S
>>  delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
>>
>
  
Adhemerval Zanella Netto Jan. 19, 2023, 2:39 p.m. UTC | #3
Just to confirm that it is for 2.38, since you replied as 2.28 on the patches :}.

On 18/01/23 19:24, Carlos O'Donell wrote:
> On 1/18/23 12:53, Adhemerval Zanella Netto wrote:
>> Carlos, do we still want this for 2.37?
> 
> I think we should just push this to 2.38.
> 
> Start by committing everything we have for x86_64 and aarch64.
> 
> Then repost the other arches for review.
>  
>> On 12/01/23 10:58, Adhemerval Zanella wrote:
>>> Currently posix_spawn has to issue at least NSIG sigaction syscalls
>>> to obtain current signal disposition and more if they there are not
>>> either SIG_IGN or SIG_DFL.  The new clone3 CLONE_CLEAR_SIGHAND flags
>>> introduced with Linux 5.5 resets all signal handlers of the child not
>>> set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this
>>> preparation phase.
>>>
>>> The exception is the signals defined by posix_spawnattr_setsigdefault
>>> when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN).  In
>>> this case posix_spawn helper process needs to issue a sigction to
>>> set the signal disposition to SIG_DFL.
>>>
>>> The patchset also adds clone3 implementation for aarch64.  The clone3
>>> for x86_64 is change to not align the stack, since this is not
>>> async-signal safe (although current calls does mask/unmask signals).
>>>
>>> * Changes from v3:
>>>   - Changes commit message and comments wording.
>>>   - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations.
>>>
>>> * Changes from v2:
>>>   - Improve clone3 internal documentation.
>>>
>>> * Changes from v1:
>>>   - Extend clone3 documentation.
>>>   - Remove x86_64 stack alignment on clone3 child.
>>>   - Fixed powerpc64 missing initial stack frame.
>>>   - Fixed missing save/restore r7 for arm.
>>>
>>> Adhemerval Zanella (6):
>>>   linux: Do not reset signal handler in posix_spawn if it is already
>>>     SIG_DFL
>>>   linux: Extend internal clone3 documentation
>>>   Linux: Do not align the stack for __clone3
>>>   linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
>>>   aarch64: Add the clone3 wrapper
>>>   Linux: optimize clone3 internal usage
>>>
>>>  include/clone_internal.h                      |  37 +++-
>>>  posix/Makefile                                |   3 +-
>>>  posix/tst-spawn7.c                            | 179 ++++++++++++++++++
>>>  sysdeps/unix/sysv/linux/Makefile              |   3 +-
>>>  sysdeps/unix/sysv/linux/aarch64/clone3.S      |  85 +++++++++
>>>  sysdeps/unix/sysv/linux/aarch64/sysdep.h      |   2 +
>>>  sysdeps/unix/sysv/linux/clone-internal.c      |  59 ++++--
>>>  sysdeps/unix/sysv/linux/clone3.h              |  15 +-
>>>  sysdeps/unix/sysv/linux/kernel-features.h     |   9 +
>>>  sysdeps/unix/sysv/linux/spawni.c              |  33 +++-
>>>  .../sysv/linux/tst-misalign-clone-internal.c  |  74 --------
>>>  sysdeps/unix/sysv/linux/x86_64/clone3.S       |   3 -
>>>  12 files changed, 384 insertions(+), 118 deletions(-)
>>>  create mode 100644 posix/tst-spawn7.c
>>>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S
>>>  delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
>>>
>>
>
  
Carlos O'Donell Jan. 22, 2023, 11:21 p.m. UTC | #4
On 1/19/23 09:39, Adhemerval Zanella Netto wrote:
> Just to confirm that it is for 2.38, since you replied as 2.28 on the patches :}.

Yes, 2.38, not 2.28 :-)

Thank you, and sorry.
 
> On 18/01/23 19:24, Carlos O'Donell wrote:
>> On 1/18/23 12:53, Adhemerval Zanella Netto wrote:
>>> Carlos, do we still want this for 2.37?
>>
>> I think we should just push this to 2.38.
>>
>> Start by committing everything we have for x86_64 and aarch64.
>>
>> Then repost the other arches for review.
>>  
>>> On 12/01/23 10:58, Adhemerval Zanella wrote:
>>>> Currently posix_spawn has to issue at least NSIG sigaction syscalls
>>>> to obtain current signal disposition and more if they there are not
>>>> either SIG_IGN or SIG_DFL.  The new clone3 CLONE_CLEAR_SIGHAND flags
>>>> introduced with Linux 5.5 resets all signal handlers of the child not
>>>> set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this
>>>> preparation phase.
>>>>
>>>> The exception is the signals defined by posix_spawnattr_setsigdefault
>>>> when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN).  In
>>>> this case posix_spawn helper process needs to issue a sigction to
>>>> set the signal disposition to SIG_DFL.
>>>>
>>>> The patchset also adds clone3 implementation for aarch64.  The clone3
>>>> for x86_64 is change to not align the stack, since this is not
>>>> async-signal safe (although current calls does mask/unmask signals).
>>>>
>>>> * Changes from v3:
>>>>   - Changes commit message and comments wording.
>>>>   - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations.
>>>>
>>>> * Changes from v2:
>>>>   - Improve clone3 internal documentation.
>>>>
>>>> * Changes from v1:
>>>>   - Extend clone3 documentation.
>>>>   - Remove x86_64 stack alignment on clone3 child.
>>>>   - Fixed powerpc64 missing initial stack frame.
>>>>   - Fixed missing save/restore r7 for arm.
>>>>
>>>> Adhemerval Zanella (6):
>>>>   linux: Do not reset signal handler in posix_spawn if it is already
>>>>     SIG_DFL
>>>>   linux: Extend internal clone3 documentation
>>>>   Linux: Do not align the stack for __clone3
>>>>   linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
>>>>   aarch64: Add the clone3 wrapper
>>>>   Linux: optimize clone3 internal usage
>>>>
>>>>  include/clone_internal.h                      |  37 +++-
>>>>  posix/Makefile                                |   3 +-
>>>>  posix/tst-spawn7.c                            | 179 ++++++++++++++++++
>>>>  sysdeps/unix/sysv/linux/Makefile              |   3 +-
>>>>  sysdeps/unix/sysv/linux/aarch64/clone3.S      |  85 +++++++++
>>>>  sysdeps/unix/sysv/linux/aarch64/sysdep.h      |   2 +
>>>>  sysdeps/unix/sysv/linux/clone-internal.c      |  59 ++++--
>>>>  sysdeps/unix/sysv/linux/clone3.h              |  15 +-
>>>>  sysdeps/unix/sysv/linux/kernel-features.h     |   9 +
>>>>  sysdeps/unix/sysv/linux/spawni.c              |  33 +++-
>>>>  .../sysv/linux/tst-misalign-clone-internal.c  |  74 --------
>>>>  sysdeps/unix/sysv/linux/x86_64/clone3.S       |   3 -
>>>>  12 files changed, 384 insertions(+), 118 deletions(-)
>>>>  create mode 100644 posix/tst-spawn7.c
>>>>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S
>>>>  delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
>>>>
>>>
>>
>
  
H.J. Lu Feb. 28, 2023, 4:34 p.m. UTC | #5
On Thu, Jan 12, 2023 at 5:59 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Currently posix_spawn has to issue at least NSIG sigaction syscalls
> to obtain current signal disposition and more if they there are not
> either SIG_IGN or SIG_DFL.  The new clone3 CLONE_CLEAR_SIGHAND flags
> introduced with Linux 5.5 resets all signal handlers of the child not
> set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this
> preparation phase.
>
> The exception is the signals defined by posix_spawnattr_setsigdefault
> when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN).  In
> this case posix_spawn helper process needs to issue a sigction to
> set the signal disposition to SIG_DFL.
>
> The patchset also adds clone3 implementation for aarch64.  The clone3
> for x86_64 is change to not align the stack, since this is not
> async-signal safe (although current calls does mask/unmask signals).
>
> * Changes from v3:
>   - Changes commit message and comments wording.
>   - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations.
>
> * Changes from v2:
>   - Improve clone3 internal documentation.
>
> * Changes from v1:
>   - Extend clone3 documentation.
>   - Remove x86_64 stack alignment on clone3 child.
>   - Fixed powerpc64 missing initial stack frame.
>   - Fixed missing save/restore r7 for arm.
>
> Adhemerval Zanella (6):
>   linux: Do not reset signal handler in posix_spawn if it is already
>     SIG_DFL
>   linux: Extend internal clone3 documentation
>   Linux: Do not align the stack for __clone3
>   linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
>   aarch64: Add the clone3 wrapper
>   Linux: optimize clone3 internal usage
>
>  include/clone_internal.h                      |  37 +++-
>  posix/Makefile                                |   3 +-
>  posix/tst-spawn7.c                            | 179 ++++++++++++++++++
>  sysdeps/unix/sysv/linux/Makefile              |   3 +-
>  sysdeps/unix/sysv/linux/aarch64/clone3.S      |  85 +++++++++
>  sysdeps/unix/sysv/linux/aarch64/sysdep.h      |   2 +
>  sysdeps/unix/sysv/linux/clone-internal.c      |  59 ++++--
>  sysdeps/unix/sysv/linux/clone3.h              |  15 +-
>  sysdeps/unix/sysv/linux/kernel-features.h     |   9 +
>  sysdeps/unix/sysv/linux/spawni.c              |  33 +++-
>  .../sysv/linux/tst-misalign-clone-internal.c  |  74 --------
>  sysdeps/unix/sysv/linux/x86_64/clone3.S       |   3 -
>  12 files changed, 384 insertions(+), 118 deletions(-)
>  create mode 100644 posix/tst-spawn7.c
>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S
>  delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
>
> --
> 2.34.1
>

On x86-64, I am getting

error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
tst-spawn7.c:91: numeric comparison failure
   left: 1 (0x1); from: WEXITSTATUS (status)
  right: 0 (0x0); from: 0
error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
tst-spawn7.c:91: numeric comparison failure
   left: 1 (0x1); from: WEXITSTATUS (status)
  right: 0 (0x0); from: 0
error: tst-spawn7.c:71: not true: sa.sa_handler == SIG_DFL
tst-spawn7.c:91: numeric comparison failure
   left: 1 (0x1); from: WEXITSTATUS (status)
  right: 0 (0x0); from: 0
error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
tst-spawn7.c:91: numeric comparison failure
   left: 1 (0x1); from: WEXITSTATUS (status)
  right: 0 (0x0); from: 0
error: 4 test failures
FAIL: posix/tst-spawn7

with

$ make check -j12

But it passes when I run it by hand.  Is this expected?
  
Adhemerval Zanella Netto Feb. 28, 2023, 5:11 p.m. UTC | #6
On 28/02/23 13:34, H.J. Lu wrote:
> On Thu, Jan 12, 2023 at 5:59 AM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> Currently posix_spawn has to issue at least NSIG sigaction syscalls
>> to obtain current signal disposition and more if they there are not
>> either SIG_IGN or SIG_DFL.  The new clone3 CLONE_CLEAR_SIGHAND flags
>> introduced with Linux 5.5 resets all signal handlers of the child not
>> set to SIG_IGN to SIG_DFL, thus allowing posix_spawn to skip this
>> preparation phase.
>>
>> The exception is the signals defined by posix_spawnattr_setsigdefault
>> when POSIX_SPAWN_SETSIGDEF is set (since they can be SIG_IGN).  In
>> this case posix_spawn helper process needs to issue a sigction to
>> set the signal disposition to SIG_DFL.
>>
>> The patchset also adds clone3 implementation for aarch64.  The clone3
>> for x86_64 is change to not align the stack, since this is not
>> async-signal safe (although current calls does mask/unmask signals).
>>
>> * Changes from v3:
>>   - Changes commit message and comments wording.
>>   - Removed powerpc, s390x, riscv, arm, and mips clone3 optimizations.
>>
>> * Changes from v2:
>>   - Improve clone3 internal documentation.
>>
>> * Changes from v1:
>>   - Extend clone3 documentation.
>>   - Remove x86_64 stack alignment on clone3 child.
>>   - Fixed powerpc64 missing initial stack frame.
>>   - Fixed missing save/restore r7 for arm.
>>
>> Adhemerval Zanella (6):
>>   linux: Do not reset signal handler in posix_spawn if it is already
>>     SIG_DFL
>>   linux: Extend internal clone3 documentation
>>   Linux: Do not align the stack for __clone3
>>   linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
>>   aarch64: Add the clone3 wrapper
>>   Linux: optimize clone3 internal usage
>>
>>  include/clone_internal.h                      |  37 +++-
>>  posix/Makefile                                |   3 +-
>>  posix/tst-spawn7.c                            | 179 ++++++++++++++++++
>>  sysdeps/unix/sysv/linux/Makefile              |   3 +-
>>  sysdeps/unix/sysv/linux/aarch64/clone3.S      |  85 +++++++++
>>  sysdeps/unix/sysv/linux/aarch64/sysdep.h      |   2 +
>>  sysdeps/unix/sysv/linux/clone-internal.c      |  59 ++++--
>>  sysdeps/unix/sysv/linux/clone3.h              |  15 +-
>>  sysdeps/unix/sysv/linux/kernel-features.h     |   9 +
>>  sysdeps/unix/sysv/linux/spawni.c              |  33 +++-
>>  .../sysv/linux/tst-misalign-clone-internal.c  |  74 --------
>>  sysdeps/unix/sysv/linux/x86_64/clone3.S       |   3 -
>>  12 files changed, 384 insertions(+), 118 deletions(-)
>>  create mode 100644 posix/tst-spawn7.c
>>  create mode 100644 sysdeps/unix/sysv/linux/aarch64/clone3.S
>>  delete mode 100644 sysdeps/unix/sysv/linux/tst-misalign-clone-internal.c
>>
>> --
>> 2.34.1
>>
> 
> On x86-64, I am getting
> 
> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: tst-spawn7.c:71: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: 4 test failures
> FAIL: posix/tst-spawn7
> 
> with
> 
> $ make check -j12
> 
> But it passes when I run it by hand.  Is this expected?
> 

I am not sure, I constantly check with make -jN (24 usually).  Can you
instrument the test to print the signal that has failed the check?
  
Florian Weimer Feb. 28, 2023, 6:09 p.m. UTC | #7
* H. J. Lu via Libc-alpha:

> On x86-64, I am getting
>
> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: tst-spawn7.c:71: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> tst-spawn7.c:91: numeric comparison failure
>    left: 1 (0x1); from: WEXITSTATUS (status)
>   right: 0 (0x0); from: 0
> error: 4 test failures
> FAIL: posix/tst-spawn7
>
> with
>
> $ make check -j12
>
> But it passes when I run it by hand.  Is this expected?

I see it as well, but it's not consistent for me, either.  Could it be a
make bug, leaking unusual handler dispositions in some cases?  The test
should probably check that the disposition are as expected at the start,
and not incorrect to begin with.

Thanks,
Florian
  
Adhemerval Zanella Netto Feb. 28, 2023, 6:16 p.m. UTC | #8
On 28/02/23 15:09, Florian Weimer wrote:
> * H. J. Lu via Libc-alpha:
> 
>> On x86-64, I am getting
>>
>> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
>> tst-spawn7.c:91: numeric comparison failure
>>    left: 1 (0x1); from: WEXITSTATUS (status)
>>   right: 0 (0x0); from: 0
>> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
>> tst-spawn7.c:91: numeric comparison failure
>>    left: 1 (0x1); from: WEXITSTATUS (status)
>>   right: 0 (0x0); from: 0
>> error: tst-spawn7.c:71: not true: sa.sa_handler == SIG_DFL
>> tst-spawn7.c:91: numeric comparison failure
>>    left: 1 (0x1); from: WEXITSTATUS (status)
>>   right: 0 (0x0); from: 0
>> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
>> tst-spawn7.c:91: numeric comparison failure
>>    left: 1 (0x1); from: WEXITSTATUS (status)
>>   right: 0 (0x0); from: 0
>> error: 4 test failures
>> FAIL: posix/tst-spawn7
>>
>> with
>>
>> $ make check -j12
>>
>> But it passes when I run it by hand.  Is this expected?
> 
> I see it as well, but it's not consistent for me, either.  Could it be a
> make bug, leaking unusual handler dispositions in some cases?  The test
> should probably check that the disposition are as expected at the start,
> and not incorrect to begin with.

Right, it makes sense. I will add some improvement to have a consistent signal
handling disposition prior spawn the tests processes.
  
H.J. Lu Feb. 28, 2023, 7:07 p.m. UTC | #9
On Tue, Feb 28, 2023 at 10:16 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 28/02/23 15:09, Florian Weimer wrote:
> > * H. J. Lu via Libc-alpha:
> >
> >> On x86-64, I am getting
> >>
> >> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> >> tst-spawn7.c:91: numeric comparison failure
> >>    left: 1 (0x1); from: WEXITSTATUS (status)
> >>   right: 0 (0x0); from: 0
> >> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> >> tst-spawn7.c:91: numeric comparison failure
> >>    left: 1 (0x1); from: WEXITSTATUS (status)
> >>   right: 0 (0x0); from: 0
> >> error: tst-spawn7.c:71: not true: sa.sa_handler == SIG_DFL
> >> tst-spawn7.c:91: numeric comparison failure
> >>    left: 1 (0x1); from: WEXITSTATUS (status)
> >>   right: 0 (0x0); from: 0
> >> error: tst-spawn7.c:55: not true: sa.sa_handler == SIG_DFL
> >> tst-spawn7.c:91: numeric comparison failure
> >>    left: 1 (0x1); from: WEXITSTATUS (status)
> >>   right: 0 (0x0); from: 0
> >> error: 4 test failures
> >> FAIL: posix/tst-spawn7
> >>
> >> with
> >>
> >> $ make check -j12
> >>
> >> But it passes when I run it by hand.  Is this expected?
> >
> > I see it as well, but it's not consistent for me, either.  Could it be a
> > make bug, leaking unusual handler dispositions in some cases?  The test
> > should probably check that the disposition are as expected at the start,
> > and not incorrect to begin with.
>
> Right, it makes sense. I will add some improvement to have a consistent signal
> handling disposition prior spawn the tests processes.

In all cases, sa.sa_handler was SIG_IGN while SIG_DFL was expected.
  
Andreas Schwab Feb. 28, 2023, 9:19 p.m. UTC | #10
On Feb 28 2023, Florian Weimer via Libc-alpha wrote:

> Could it be a make bug, leaking unusual handler dispositions in some
> cases?

Don't use make 4.4, it's broken.
  
H.J. Lu Feb. 28, 2023, 9:31 p.m. UTC | #11
On Tue, Feb 28, 2023 at 1:19 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Feb 28 2023, Florian Weimer via Libc-alpha wrote:
>
> > Could it be a make bug, leaking unusual handler dispositions in some
> > cases?
>
> Don't use make 4.4, it's broken.
>

I am using make 4.3 on Fedora 37.