mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo/internal/test: skip TestMultipleAssign when using UCRT on Windows
The Universal C Runtime (UCRT) default behavior is to crash the program when strtol is called with an invalid base (that is, not 0 or 2..36). This an invalid base (that is, not 0 or 2..36). This changes the test to skip when running on Windows and linking with UCRT. When using external linking mode this test passes if using the Mingw-w64 toolchain, even when linking with UCRT. That's because the Mingw-w64 linker adds a _set_invalid_parameter_handler call at startup that overrides the default UCRT behavior. However, other toolchains, like MSVC and LLVM, doesn't override the default behavior. Overriding the default behavior is out of the scope for this test, so the test is skipped instead. Fixes #62887 Change-Id: I60f140faf0eda80a2de4e10876be25e0dbe442d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/705455 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
32dfd69282
commit
2353c15785
3 changed files with 29 additions and 2 deletions
|
|
@ -1096,6 +1096,12 @@ func testErrno(t *testing.T) {
|
|||
}
|
||||
|
||||
func testMultipleAssign(t *testing.T) {
|
||||
if runtime.GOOS == "windows" && usesUCRT(t) {
|
||||
// UCRT's strtol throws an unrecoverable crash when
|
||||
// using an invalid base (that is, not 0 or 2..36).
|
||||
// See go.dev/issue/62887.
|
||||
t.Skip("skipping test on Windows when linking with UCRT")
|
||||
}
|
||||
p := C.CString("234")
|
||||
n, m := C.strtol(p, nil, 345), C.strtol(p, nil, 10)
|
||||
defer C.free(unsafe.Pointer(p))
|
||||
|
|
|
|||
|
|
@ -6,6 +6,13 @@
|
|||
|
||||
package cgotest
|
||||
|
||||
import "syscall"
|
||||
import (
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var syscall_dot_SIGCHLD = syscall.SIGCHLD
|
||||
|
||||
func usesUCRT(t *testing.T) bool {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,20 @@
|
|||
|
||||
package cgotest
|
||||
|
||||
import "syscall"
|
||||
import (
|
||||
"internal/syscall/windows"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var syscall_dot_SIGCHLD syscall.Signal
|
||||
|
||||
// usesUCRT reports whether the test is using the Windows UCRT (Universal C Runtime).
|
||||
func usesUCRT(t *testing.T) bool {
|
||||
name, err := syscall.UTF16PtrFromString("ucrtbase.dll")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h, err := windows.GetModuleHandle(name)
|
||||
return err == nil && h != 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue