Skip to content

[Stdlib] Make alignedStorageForEmptyVaLists bigger. #79774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion stdlib/public/core/VarArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,14 @@ final internal class __VaListBuilder {
internal var retainer = [CVarArg]()
#endif

internal static var alignedStorageForEmptyVaLists: Double = 0
// Some code will call a variadic function without passing variadic parameters
// where the function will still attempt to read variadic parameters. For
// example, calling printf with an arbitrary string as the format string. This
// is inherently unsound, but we'll try to be nice to such code by giving it
// 64 bytes of zeroes in that case.
internal static var alignedStorageForEmptyVaLists:
(Double, Double, Double, Double, Double, Double, Double, Double)
= (0, 0, 0, 0, 0, 0, 0, 0)
}

#endif
Expand Down
14 changes: 14 additions & 0 deletions test/stdlib/VarArgs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@ func test_varArgs6() {
}
test_varArgs6()

func test_varArgs7() {
#if canImport(Darwin) && arch(arm64)
// Test a workaround for format specifiers and no arguments. We supply eight
// words of zeroed memory to give this predictable behavior.
my_printf("No parameters: %ld %ld %ld %ld %ld %ld %ld %ld\n")
#else
// va_list is more complicated on other targets so that behavior is not the
// same, skip the test by doing a fake print of the expected output.
my_printf("No parameters: 0 0 0 0 0 0 0 0\n")
#endif
// CHECK: No parameters: 0 0 0 0 0 0 0 0
}
test_varArgs7()


// CHECK: done.
my_printf("done.")