Bug 455711

Summary: Syscall param sigaltstack(ss) points to uninitialised byte(s) when only ss.ss_flags = SS_DISABLE
Product: [Developer tools] valgrind Reporter: Richard Jones <rjones>
Component: memcheckAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Richard Jones 2022-06-21 11:19:56 UTC
SUMMARY

The OCaml compiler calls sigaltstack using code similar to this:

#include <stdlib.h>
#include <signal.h>

int
main ()
{
  stack_t ss;
  ss.ss_flags = SS_DISABLE;
  sigaltstack (&ss, NULL);
}

According to the docs this is fine, you don't need to initialize the other fields in the struct if you are disabling the alternate stack.  However valgrind complains:

==382696== Syscall param sigaltstack(ss) points to uninitialised byte(s)
==382696==    at 0x48AD42B: sigaltstack (syscall-template.S:120)
==382696==    by 0x401145: main (in /var/tmp/sigaltstack)
==382696==  Address 0x1ffefff930 is on thread 1's stack
==382696==  in frame #1, created by main (???:)

This happens when running any OCaml program under valgrind.  Original bug report:
https://github.com/ocaml/ocaml/issues/11335
https://github.com/ocaml/ocaml/blob/2c2e99049a5189bb874d215968435cc1e8a375ea/runtime/signals_nat.c#L349

STEPS TO REPRODUCE
1.  Compile the above program and run it under valgrind.

SOFTWARE/OS VERSIONS

Linux: Fedora 37 valgrind-3.19.0-3.fc37.x86_64