((∑[T𝒰]∏A∈T]A≃1
2023-10-20T02:46:23.000Z
ARM 的 variadic function calling convention 跟 x86 不一樣What About ... ?所以有些 x86 下意外會動的 FFI 程式碼到 Mac M1 可能會 segfault
((∑[T𝒰]∏A∈T]A≃1 好奇
2023-10-20T02:47:56.000Z
((∑[T𝒰]∏A∈T]A≃1
2023-10-20T02:49:07.000Z
Addressing Architectural Differences in Your macOS C...> The x86_64 and arm64 architectures have different calling conventions for variadic functions—functions with a variable number of parameters. On x86_64, the compiler treats fixed and variadic parameters the same, placing parameters in registers first and only using the stack when no more registers are available.
((∑[T𝒰]∏A∈T]A≃1
2023-10-20T02:49:10.000Z
> On arm64, the compiler always places variadic parameters on the stack, regardless of whether registers are available. If you implement a function with fixed parameters, but redeclare it with variadic parameters, the mismatch causes unexpected behavior at runtime.
立即下載
((∑[T𝒰]∏A∈T]A≃1
2023-10-20T02:49:53.000Z
所以程式碼裡面原本 segfault, 加了個 printf 後可能就不會 segfault, 只是會變處理垃圾參數 XDDD