Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-62387

go binary segfaults under valgrind on ppc64le

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • rhel-10.0
    • valgrind
    • None
    • No
    • Low
    • rhel-sst-pt-perf-debug
    • ssg_platform_tools
    • 2
    • False
    • Hide

      None

      Show
      None
    • No
    • None
    • None
    • None
    • Unspecified Release Note Type - Unknown
    • ppc64le
    • None

      Similarly to RHEL-61945, several golang crypto testcases executed with valgrind fail with SIGSEGV on ppc64le, but also noticed that this is often reproducible with a smaller example:

      [root@ibm-p10-01-lp42 decrypt]# cat decrypt.go 
      // https://pkg.go.dev/crypto/cipher#example-NewGCM-Decrypt
      package main
      
      import (
      	"crypto/aes"
      	"crypto/cipher"
      	"encoding/hex"
      	"fmt"
      )
      
      func main() {
      	// Load your secret key from a safe place and reuse it across multiple
      	// Seal/Open calls. (Obviously don't use this example key for anything
      	// real.) If you want to convert a passphrase to a key, use a suitable
      	// package like bcrypt or scrypt.
      	// When decoded the key should be 16 bytes (AES-128) or 32 (AES-256).
      	key, _ := hex.DecodeString("6368616e676520746869732070617373776f726420746f206120736563726574")
      	ciphertext, _ := hex.DecodeString("c3aaa29f002ca75870806e44086700f62ce4d43e902b3888e23ceff797a7a471")
      	nonce, _ := hex.DecodeString("64a9433eae7ccceee2fc0eda")
      
      	block, err := aes.NewCipher(key)
      	if err != nil {
      		panic(err.Error())
      	}
      
      	aesgcm, err := cipher.NewGCM(block)
      	if err != nil {
      		panic(err.Error())
      	}
      
      	plaintext, err := aesgcm.Open(nil, nonce, ciphertext, nil)
      	if err != nil {
      		panic(err.Error())
      	}
      
      	fmt.Printf("%s\n", plaintext)
      }
      [root@ibm-p10-01-lp42 decrypt]# go build -o decrypt decrypt.go 
      [root@ibm-p10-01-lp42 decrypt]# while true; do valgrind ./decrypt || break; echo; done
      (...)
      ==523785== Memcheck, a memory error detector
      ==523785== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
      ==523785== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
      ==523785== Command: ./decrypt
      ==523785== 
      ==523785== Warning: set address range perms: large range [0x109f0000, 0x309f0000) (noaccess)
      ==523785== Warning: set address range perms: large range [0x309f0000, 0x509f0000) (noaccess)
      ==523785== Warning: ignored attempt to set SIGRT32 handler in sigaction();
      ==523785==          the SIGRT32 signal is used internally by Valgrind
      ==523785== Warning: ignored attempt to set SIGRT32 handler in sigaction();
      ==523785==          the SIGRT32 signal is used internally by Valgrind
      ==523785== Warning: client switching stacks?  SP change: 0x1fff00e790 --> 0xc0000547c0
      ==523785==          to suppress, use: --max-stackframe=687211831344 or greater
      ==523785== Warning: client switching stacks?  SP change: 0xc000054718 --> 0x1fff00e868
      ==523785==          to suppress, use: --max-stackframe=687211830960 or greater
      ==523785== Warning: client switching stacks?  SP change: 0x1fff00e868 --> 0xc000054718
      ==523785==          to suppress, use: --max-stackframe=687211830960 or greater
      ==523785==          further instances of this message will not be shown.
      ==523785== Conditional jump or move depends on uninitialised value(s)
      ==523785==    at 0x10053990: runtime.adjustframe (stack.go:585)
      ==523785== 
      ==523785== Conditional jump or move depends on uninitialised value(s)
      ==523785==    at 0x1005399C: runtime.adjustframe (stack.go:585)
      ==523785== 
      ==523785== Invalid read of size 8
      ==523785==    at 0x10050CF0: runtime.(*sigctxt).pc (signal_linux_ppc64x.go:60)
      ==523785==    by 0x10050CF0: runtime.(*sigctxt).sigpc (signal_ppc64x.go:58)
      ==523785==    by 0x10050CF0: runtime.sighandler (signal_unix.go:685)
      ==523785==  Address 0x100 is not stack'd, malloc'd or (recently) free'd
      ==523785== 
      ==523785== 
      ==523785== Process terminating with default action of signal 11 (SIGSEGV): dumping core
      ==523785==  Access not within mapped region at address 0x100
      ==523785==    at 0x10050CF0: runtime.(*sigctxt).pc (signal_linux_ppc64x.go:60)
      ==523785==    by 0x10050CF0: runtime.(*sigctxt).sigpc (signal_ppc64x.go:58)
      ==523785==    by 0x10050CF0: runtime.sighandler (signal_unix.go:685)
      ==523785==  If you believe this happened as a result of a stack
      ==523785==  overflow in your program's main thread (unlikely but
      ==523785==  possible), you can try to increase the size of the
      ==523785==  main thread stack using the --main-stacksize= flag.
      ==523785==  The main thread stack size used in this run was 8388608.
      ==523785== 
      ==523785== HEAP SUMMARY:
      ==523785==     in use at exit: 1,440 bytes in 5 blocks
      ==523785==   total heap usage: 17 allocs, 12 frees, 3,632 bytes allocated
      ==523785== 
      ==523785== LEAK SUMMARY:
      ==523785==    definitely lost: 0 bytes in 0 blocks
      ==523785==    indirectly lost: 0 bytes in 0 blocks
      ==523785==      possibly lost: 1,440 bytes in 5 blocks
      ==523785==    still reachable: 0 bytes in 0 blocks
      ==523785==         suppressed: 0 bytes in 0 blocks
      ==523785== Rerun with --leak-check=full to see details of leaked memory
      ==523785== 
      ==523785== Use --track-origins=yes to see where uninitialised values come from
      ==523785== For lists of detected and suppressed errors, rerun with: -s
      ==523785== ERROR SUMMARY: 6 errors from 3 contexts (suppressed: 0 from 0)
      Segmentation fault (core dumped)
      

      This is more easily reproducible if running valgrind with some additional parameters

      Please provide the package NVR for which the bug is seen:

      openssl-3.2.2-12.el10.ppc64le
      golang-1.23.1-2.el10.ppc64le
      valgrind-3.23.0-4.el10.ppc64le

      How reproducible is this bug?:

      Occasionally. More easily reproducible when running valgrind with additional parameters (e.g. valgrind --trace-children=yes --track-origins=yes --leak-check=full --fair-sched=try ...).

      Steps to reproduce

      1. # yum install -y golang golang-tests valgrind
      2. # go build -o decrypt decrypt.go
      3. # while true; do valgrind ./decrypt || break; echo; done

              rhn-engineering-mjw Mark Wielaard
              rhn-support-emachado Edjunior Machado
              Mark Wielaard Mark Wielaard
              qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated: