Bug 455711 - Syscall param sigaltstack(ss) points to uninitialised byte(s) when only ss.ss_flags = SS_DISABLE
Summary: Syscall param sigaltstack(ss) points to uninitialised byte(s) when only ss.ss...
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-21 11:19 UTC by Richard Jones
Modified: 2022-06-21 11:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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