Skip to content

Drop FFI pin, plus a bunch of assorted other bits #14911

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jaymzh
Copy link
Collaborator

@jaymzh jaymzh commented Mar 18, 2025

  • Add msys2 build-dep to windows hab so we can build libffi
    which is required in ffi 1.17.x
  • Add some post-bundle-install hacks for appbunder for ffi 1.17.x
  • Sort words in cspell config after adding 'autoreconf'

See ffi/ffi#1139 (comment)
for details

$ bundle update ffi ohai mixlib-log --conservative
Fetching https://github.com/stanhu/mixlib-log.git
Fetching https://github.com/jaymzh/ohai.git
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Resolving dependencies...
Using mixlib-log 3.2.2 (was 3.0.9) from https://github.com/stanhu/mixlib-log.git (at sh-relax-ffi@6aff216)
Using ohai 19.0.9 (was 19.0.5) from https://github.com/jaymzh/ohai.git (at ffi-ver@1c34928)
Bundler attempted to update ffi but its version stayed the same
Bundle updated!

Signed-off-by: Phil Dibowitz phil@ipom.com

@jaymzh jaymzh requested review from a team as code owners March 18, 2025 18:30
@jaymzh
Copy link
Collaborator Author

jaymzh commented Mar 18, 2025

This requires the fix in ohai from chef/ohai#1866

Tested this with:

-gem "ohai", git: "https://github.com/chef/ohai.git", branch: "main"
+gem "ohai", git: "https://github.com/jaymzh/ohai.git", branch: "ffi-ver"

and it builds.

@jaymzh
Copy link
Collaborator Author

jaymzh commented Mar 18, 2025

Looks like there's a lot more sticking us to 1.15

  • rest-client - we're pinned to some very specific branch which is pinned to ffi ~> 1.15.
  • chef-powershell - same

@jaymzh
Copy link
Collaborator Author

jaymzh commented Mar 18, 2025

rest-client isn't pinned, that inherited the pin from us... so just chef-powershell.

@jaymzh
Copy link
Collaborator Author

jaymzh commented Mar 18, 2025

OK chef/chef-powershell-shim#288 is for chef-powershell. There's no direct dep, but it's pulled in from somewhere.

@jaymzh jaymzh force-pushed the ffi-ver branch 2 times, most recently from 0e1a97c to 40439eb Compare March 25, 2025 21:57
@jaymzh jaymzh force-pushed the ffi-ver branch 9 times, most recently from 5e9e1f0 to 243dc8c Compare March 30, 2025 01:43
@jaymzh
Copy link
Collaborator Author

jaymzh commented Mar 30, 2025

@tpowell-progress - as discussed in Slack, this needs a release of mixlib-log to rubygems, then another bundle update.

HOWEVER - any idea why fips is failing to find ruby?

@jaymzh jaymzh force-pushed the ffi-ver branch 10 times, most recently from edaaa49 to 0a41cc1 Compare April 2, 2025 01:00
@jaymzh jaymzh force-pushed the ffi-ver branch 11 times, most recently from 4fc3dff to b602254 Compare April 3, 2025 16:50
@stanhu
Copy link
Contributor

stanhu commented Apr 3, 2025

On both macOS 13 and 15, for some reason I'm unable to get spec/functional/resource/macos_userdefaults_spec.rb to pass with any version of ffi:

% bundle exec rspec spec/functional/resource/macos_userdefaults_spec.rb
Run options:
  include {:focus=>true}
  exclude {:provider=>#<Proc: ./spec/spec_helper.rb:217>, :arch=>#<Proc: ./spec/spec_helper.rb:211>, :pwsh_installed=>true, :choco_installed=>true, :ruby=>"3.1.7", :chef=>"19.1.11", :not_intel_64bit=>true, :rhel_gte_8=>true, :rhel8=>true, :rhel7=>true, :rhel6=>true, :rhel=>true, :not_supported_on_s390x=>true, :not_wpar=>true, :broken=>true, :openssl_version_check=>true, :openssl_lt_101=>true, :requires_root_or_running_windows=>true, :requires_root=>true, :selinux_only=>true, :debian_family_only=>true, :opensuse=>true, :suse_only=>true, :aix_only=>true, :linux_only=>true, :solaris_only=>true, :windows_domain_joined_only=>true, :windows_powershell_dsc_only=>true, :ruby32_only=>true, :windows_gte_10=>true, :windows32_only=>true, :windows64_only=>true, :win2012r2_only=>true, :not_macos_gte_11=>true, :not_supported_on_macos=>true, :windows_only=>true, :fips_mode_negative_test=>true, :fips_mode_test=>true, :volatile_from_verify=>false, :volatile=>true, :external=>true}

All examples were filtered out; ignoring {:focus=>true}
........FFFF..FF

Failures:

  1) Chef::Resource::MacosUserDefaults can process expected data set array values
     Failure/Error: CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host))

     CF::Exceptions::PreferenceSyncFailed:
       macos_userdefaults[test] (dynamically defined) had an error: CF::Exceptions::PreferenceSyncFailed: Couldn't write preference value for "TestArrayValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     # ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'
     # ./lib/chef/mixin/why_run.rb:51:in `add_action'
     # ./lib/chef/provider.rb:293:in `converge_by'
     # ./lib/chef/provider.rb:390:in `converge_if_changed'
     # ./lib/chef/resource/macos_userdefaults.rb:120:in `block in <class:MacosUserDefaults>'
     # (eval):2:in `block in action_write'
     # ./lib/chef/provider.rb:304:in `instance_eval'
     # ./lib/chef/provider.rb:304:in `compile_and_converge_action'
     # (eval):2:in `action_write'
     # ./lib/chef/provider.rb:245:in `run_action'
     # ./lib/chef/resource.rb:601:in `block in run_action'
     # ./lib/chef/resource.rb:629:in `with_umask'
     # ./lib/chef/resource.rb:600:in `run_action'
     # ./spec/functional/resource/macos_userdefaults_spec.rb:64:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:318:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # CF::Exceptions::PreferenceSyncFailed:
     #   Couldn't write preference value for "TestArrayValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     #   ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'

  2) Chef::Resource::MacosUserDefaults can process expected data set dictionary value
     Failure/Error: CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host))

     CF::Exceptions::PreferenceSyncFailed:
       macos_userdefaults[test] (dynamically defined) had an error: CF::Exceptions::PreferenceSyncFailed: Couldn't write preference value for "TestDictionaryValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     # ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'
     # ./lib/chef/mixin/why_run.rb:51:in `add_action'
     # ./lib/chef/provider.rb:293:in `converge_by'
     # ./lib/chef/provider.rb:390:in `converge_if_changed'
     # ./lib/chef/resource/macos_userdefaults.rb:120:in `block in <class:MacosUserDefaults>'
     # (eval):2:in `block in action_write'
     # ./lib/chef/provider.rb:304:in `instance_eval'
     # ./lib/chef/provider.rb:304:in `compile_and_converge_action'
     # (eval):2:in `action_write'
     # ./lib/chef/provider.rb:245:in `run_action'
     # ./lib/chef/resource.rb:601:in `block in run_action'
     # ./lib/chef/resource.rb:629:in `with_umask'
     # ./lib/chef/resource.rb:600:in `run_action'
     # ./spec/functional/resource/macos_userdefaults_spec.rb:72:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:318:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # CF::Exceptions::PreferenceSyncFailed:
     #   Couldn't write preference value for "TestDictionaryValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     #   ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'

  3) Chef::Resource::MacosUserDefaults can process expected data set array of dictionaries
     Failure/Error: CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host))

     CF::Exceptions::PreferenceSyncFailed:
       macos_userdefaults[test] (dynamically defined) had an error: CF::Exceptions::PreferenceSyncFailed: Couldn't write preference value for "TestArrayWithDictionary" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     # ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'
     # ./lib/chef/mixin/why_run.rb:51:in `add_action'
     # ./lib/chef/provider.rb:293:in `converge_by'
     # ./lib/chef/provider.rb:390:in `converge_if_changed'
     # ./lib/chef/resource/macos_userdefaults.rb:120:in `block in <class:MacosUserDefaults>'
     # (eval):2:in `block in action_write'
     # ./lib/chef/provider.rb:304:in `instance_eval'
     # ./lib/chef/provider.rb:304:in `compile_and_converge_action'
     # (eval):2:in `action_write'
     # ./lib/chef/provider.rb:245:in `run_action'
     # ./lib/chef/resource.rb:601:in `block in run_action'
     # ./lib/chef/resource.rb:629:in `with_umask'
     # ./lib/chef/resource.rb:600:in `run_action'
     # ./spec/functional/resource/macos_userdefaults_spec.rb:80:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:318:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # CF::Exceptions::PreferenceSyncFailed:
     #   Couldn't write preference value for "TestArrayWithDictionary" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     #   ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'

  4) Chef::Resource::MacosUserDefaults can process expected data set boolean for preference value
     Failure/Error: CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host))

     CF::Exceptions::PreferenceSyncFailed:
       macos_userdefaults[test] (dynamically defined) had an error: CF::Exceptions::PreferenceSyncFailed: Couldn't write preference value for "TestBooleanValue" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     # ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'
     # ./lib/chef/mixin/why_run.rb:51:in `add_action'
     # ./lib/chef/provider.rb:293:in `converge_by'
     # ./lib/chef/provider.rb:390:in `converge_if_changed'
     # ./lib/chef/resource/macos_userdefaults.rb:120:in `block in <class:MacosUserDefaults>'
     # (eval):2:in `block in action_write'
     # ./lib/chef/provider.rb:304:in `instance_eval'
     # ./lib/chef/provider.rb:304:in `compile_and_converge_action'
     # (eval):2:in `action_write'
     # ./lib/chef/provider.rb:245:in `run_action'
     # ./lib/chef/resource.rb:601:in `block in run_action'
     # ./lib/chef/resource.rb:629:in `with_umask'
     # ./lib/chef/resource.rb:600:in `run_action'
     # ./spec/functional/resource/macos_userdefaults_spec.rb:88:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:318:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # CF::Exceptions::PreferenceSyncFailed:
     #   Couldn't write preference value for "TestBooleanValue" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     #   ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'

  5) Chef::Resource::MacosUserDefaults resource can process FFI::Pointer type for host property
     Failure/Error: CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host))

     CF::Exceptions::PreferenceSyncFailed:
       macos_userdefaults[test] (dynamically defined) had an error: CF::Exceptions::PreferenceSyncFailed: Couldn't write preference value for "TestDictionaryValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdfd8>
     # ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'
     # ./lib/chef/mixin/why_run.rb:51:in `add_action'
     # ./lib/chef/provider.rb:293:in `converge_by'
     # ./lib/chef/provider.rb:374:in `converge_if_changed'
     # ./lib/chef/resource/macos_userdefaults.rb:120:in `block in <class:MacosUserDefaults>'
     # (eval):2:in `block in action_write'
     # ./lib/chef/provider.rb:304:in `instance_eval'
     # ./lib/chef/provider.rb:304:in `compile_and_converge_action'
     # (eval):2:in `action_write'
     # ./lib/chef/provider.rb:245:in `run_action'
     # ./lib/chef/resource.rb:601:in `block in run_action'
     # ./lib/chef/resource.rb:629:in `with_umask'
     # ./lib/chef/resource.rb:600:in `run_action'
     # ./spec/functional/resource/macos_userdefaults_spec.rb:126:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:318:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # CF::Exceptions::PreferenceSyncFailed:
     #   Couldn't write preference value for "TestDictionaryValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdfd8>
     #   ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'

  6) Chef::Resource::MacosUserDefaults resource can process FFI::Pointer type for user property
     Failure/Error: CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host))

     CF::Exceptions::PreferenceSyncFailed:
       macos_userdefaults[test] (dynamically defined) had an error: CF::Exceptions::PreferenceSyncFailed: Couldn't write preference value for "TestDictionaryValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     # ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'
     # ./lib/chef/mixin/why_run.rb:51:in `add_action'
     # ./lib/chef/provider.rb:293:in `converge_by'
     # ./lib/chef/provider.rb:374:in `converge_if_changed'
     # ./lib/chef/resource/macos_userdefaults.rb:120:in `block in <class:MacosUserDefaults>'
     # (eval):2:in `block in action_write'
     # ./lib/chef/provider.rb:304:in `instance_eval'
     # ./lib/chef/provider.rb:304:in `compile_and_converge_action'
     # (eval):2:in `action_write'
     # ./lib/chef/provider.rb:245:in `run_action'
     # ./lib/chef/resource.rb:601:in `block in run_action'
     # ./lib/chef/resource.rb:629:in `with_umask'
     # ./lib/chef/resource.rb:600:in `run_action'
     # ./spec/functional/resource/macos_userdefaults_spec.rb:135:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:318:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # CF::Exceptions::PreferenceSyncFailed:
     #   Couldn't write preference value for "TestDictionaryValues" in "/Library/Preferences/ManagedInstalls", hostname: #<FFI::Pointer address=0x00007ff85d4cdf78>
     #   ./lib/chef/resource/macos_userdefaults.rb:122:in `block (2 levels) in <class:MacosUserDefaults>'

Finished in 0.04185 seconds (files took 2.14 seconds to load)
16 examples, 6 failures

Failed examples:

rspec ./spec/functional/resource/macos_userdefaults_spec.rb:60 # Chef::Resource::MacosUserDefaults can process expected data set array values
rspec ./spec/functional/resource/macos_userdefaults_spec.rb:68 # Chef::Resource::MacosUserDefaults can process expected data set dictionary value
rspec ./spec/functional/resource/macos_userdefaults_spec.rb:76 # Chef::Resource::MacosUserDefaults can process expected data set array of dictionaries
rspec ./spec/functional/resource/macos_userdefaults_spec.rb:84 # Chef::Resource::MacosUserDefaults can process expected data set boolean for preference value
rspec ./spec/functional/resource/macos_userdefaults_spec.rb:121 # Chef::Resource::MacosUserDefaults resource can process FFI::Pointer type for host property
rspec ./spec/functional/resource/macos_userdefaults_spec.rb:130 # Chef::Resource::MacosUserDefaults resource can process FFI::Pointer type for user property

@stanhu
Copy link
Contributor

stanhu commented Apr 3, 2025

sudo log stream shows these errors:

2025-04-03 17:18:01.012617+0000 0x21207    Error       0x0                  64193  0    ruby: (CoreFoundation) [com.apple.defaults:User Defaults] attempt to set <private> for key in <private> in read-only (due to a previously logged write error) preferences domain CFPrefsPlistSource<0x600003a55f00> (Domain: ManagedInstalls, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: No)
2025-04-03 17:18:01.014406+0000 0x21207    Error       0x0                  64193  0    ruby: (CoreFoundation) [com.apple.defaults:User Defaults] attempt to set <private> for key in <private> in read-only (due to a previously logged write error) preferences domain CFPrefsPlistSource<0x600003a55f00> (Domain: ManagedInstalls, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: No)
2025-04-03 17:18:01.015686+0000 0x21207    Error       0x0                  64193  0    ruby: (CoreFoundation) [com.apple.defaults:User Defaults] attempt to set <private> for key in <private> in read-only (due to a previously logged write error) preferences domain CFPrefsPlistSource<0x600003a55f00> (Domain: ManagedInstalls, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: No)
2025-04-03 17:18:01.017038+0000 0x21207    Activity    0x25934              64193  0    ruby: (CoreFoundation) Loading Preferences From User CFPrefsD
2025-04-03 17:18:01.024559+0000 0x21207    Error       0x0                  64193  0    ruby: (CoreFoundation) [com.apple.defaults:User Defaults] attempt to set <private> for key in <private> in read-only (due to a previously logged write error) preferences domain CFPrefsPlistSource<0x600003a55f00> (Domain: ManagedInstalls, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: No)
2025-04-03 17:18:01.026395+0000 0x21207    Error       0x0                  64193  0    ruby: (CoreFoundation) [com.apple.defaults:User Defaults] attempt to set <private> for key in <private> in read-only (due to a previously logged write error) preferences domain CFPrefsPlistSource<0x600003a55f00> (Domain: ManagedInstalls, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: No)

Looks like the process is trying to update preferences in ManagedInstalls. sudo didn't seem to help.

I wonder why this test attempts to modify this system preference instead of creating a test app.

@stanhu
Copy link
Contributor

stanhu commented Apr 3, 2025

I applied this diff:

diff --git a/spec/functional/resource/macos_userdefaults_spec.rb b/spec/functional/resource/macos_userdefaults_spec.rb
index 2d3f538cf2..5063f64db8 100644
--- a/spec/functional/resource/macos_userdefaults_spec.rb
+++ b/spec/functional/resource/macos_userdefaults_spec.rb
@@ -58,7 +58,7 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do

   context "can process expected data" do
     it "set array values" do
-      resource.domain "/Library/Preferences/ManagedInstalls"
+      resource.domain "#{ENV['HOME']}/Library/Preferences/com.chef.macos.test.preferences"
       resource.key "TestArrayValues"
       resource.value [ "/Library/Managed Installs/fake.log", "/Library/Managed Installs/also_fake.log"]
       resource.run_action(:write)
@@ -66,7 +66,7 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
     end

     it "set dictionary value" do
-      resource.domain "/Library/Preferences/ManagedInstalls"
+      resource.domain "#{ENV['HOME']}/Library/Preferences/com.chef.macos.test.preferences"
       resource.key "TestDictionaryValues"
       resource.value "User": "/Library/Managed Installs/way_fake.log"
       resource.run_action(:write)
@@ -74,7 +74,7 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
     end

     it "set array of dictionaries" do
-      resource.domain "/Library/Preferences/ManagedInstalls"
+      resource.domain "#{ENV['HOME']}/Library/Preferences/com.chef.macos.test.preferences"
       resource.key "TestArrayWithDictionary"
       resource.value [ { "User": "/Library/Managed Installs/way_fake.log" } ]
       resource.run_action(:write)
@@ -82,7 +82,7 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
     end

     it "set boolean for preference value" do
-      resource.domain "/Library/Preferences/ManagedInstalls"
+      resource.domain "#{ENV['HOME']}/Library/Preferences/com.chef.macos.test.preferences"
       resource.key "TestBooleanValue"
       resource.value true
       resource.run_action(:write)
@@ -106,7 +106,7 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
   end

   it "we can delete a preference with full path" do
-    resource.domain "/Library/Preferences/ManagedInstalls"
+    resource.domain "#{ENV['HOME']}/Library/Preferences/com.chef.macos.test.preferences"
     resource.key "TestKey"
     expect { resource.run_action(:delete) }. to_not raise_error
   end
@@ -119,7 +119,7 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do

   context "resource can process FFI::Pointer type" do
     it "for host property" do
-      resource.domain "/Library/Preferences/ManagedInstalls"
+      resource.domain "#{ENV['HOME']}/Library/Preferences/com.chef.macos.test.preferences"
       resource.key "TestDictionaryValues"
       resource.value "User": "/Library/Managed Installs/way_fake.log"
       resource.host :current
@@ -128,7 +128,7 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
     end

     it "for user property" do
-      resource.domain "/Library/Preferences/ManagedInstalls"
+      resource.domain "#{ENV['HOME']}/Library/Preferences/com.chef.macos.test.preferences"
       resource.key "TestDictionaryValues"
       resource.value "User": "/Library/Managed Installs/way_fake.log"
       resource.user :current

This worked fine with macOS 13 and 15 with ffi v1.17.1, both precompiled and compiled versions.

@stanhu stanhu mentioned this pull request Apr 3, 2025
11 tasks
@stanhu
Copy link
Contributor

stanhu commented Apr 3, 2025

#14937 seems to work locally and in CI.

@stanhu
Copy link
Contributor

stanhu commented Apr 15, 2025

@jaymzh Can you try rebasing main to pick up #14937 and updating to ffi v1.17.2? I'm curious if this helps with the macOS 13 failures.

* Add msys2 build-dep to windows hab so we can build libffi
  which is required in ffi 1.17.x
* Add some post-bundle-install hacks for appbunder for ffi 1.17.x
* Sort words in cspell config after adding 'autoreconf'

See ffi/ffi#1139 (comment)
for details

```
$ bundle update ffi ohai mixlib-log --conservative
Fetching https://github.com/stanhu/mixlib-log.git
Fetching https://github.com/jaymzh/ohai.git
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Resolving dependencies...
Using mixlib-log 3.2.2 (was 3.0.9) from https://github.com/stanhu/mixlib-log.git (at sh-relax-ffi@6aff216)
Using ohai 19.0.9 (was 19.0.5) from https://github.com/jaymzh/ohai.git (at ffi-ver@1c34928)
Bundler attempted to update ffi but its version stayed the same
Bundle updated!
```

Signed-off-by: Phil Dibowitz <phil@ipom.com>
@stanhu
Copy link
Contributor

stanhu commented Apr 15, 2025

The seg fault in macOS 13 came up again: https://github.com/chef/chef/actions/runs/14474375159/job/40596279236

I wonder why I can't reproduce that.

@jaymzh
Copy link
Collaborator Author

jaymzh commented Apr 15, 2025

The mac fixes from your PR, but not the segfault.

@jaymzh
Copy link
Collaborator Author

jaymzh commented Apr 15, 2025

Heh. Jinx.

Yeah, it's pretty bizarre. I wonder if there's something specific to GH's runners. There's no Mac tests on BK, so no good way to compare.

@stanhu
Copy link
Contributor

stanhu commented Apr 15, 2025

Oh, right, #14937 only updates the Chef tests. The actual Kitchen tests still use the /Library/Preferences/ManagedInstalls domain, which I don't have on my local system.

There's a possibility that there is a memory access bug here with either ffi or libffi only for macOS 13 when reading out the CF Preferences array. I can't reproduce it on my macOS 13 system.

I have to wonder if the Kitchen tests used a temporary file as #14937 does whether we'd see the seg fault.

macOS 13 reaches EOL in November 2025 in any case, so I wonder if it's easier at this point to drop support for that.

@jaymzh
Copy link
Collaborator Author

jaymzh commented Apr 15, 2025

We can't drop support for an OS nearly a full year before it's EOL date...

@stanhu
Copy link
Contributor

stanhu commented Apr 15, 2025

I wonder if we need to build the ffi gem with --disable-system-libffi, at least for macOS 13. It looks like the gem might have linked against /opt/chef/embedded/lib/libffi.8.dylib, so I wonder if there is some minor incompatibility with that version.

@stanhu
Copy link
Contributor

stanhu commented Apr 15, 2025

Ok, I was able to reproduce this issue on macOS 13 if I follow the Kitchen steps:

brew install coreutils
sudo su
curl https://omnitruck.chef.io/install.sh | bash -s -- -P chef -c current
export PATH="/opt/chef/bin:/opt/chef/embedded/bin:$PATH"
<clone this branch>
cd chef
bundle install
gem install ohai
/opt/chef/embedded/bin/ruby /opt/chef/embedded/bin/rake install:local
gem uninstall ffi --platform x86-darwin

Then I ran irb and ran this script:

require 'chef'

events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
run_context = Chef::RunContext.new(node, {}, events)

 r = Chef::Resource::MacosUserDefaults.new("Value with space", run_context).tap do |r|
  r.value = [ "/Library/Managed Installs/fake.log", "/Library/Managed Installs/also_fake.log", "hello"]
  r.key = "test-test"
end

r.run_action(:write)
r.get_preference(r)

On macOS 13, the seg fault doesn't happen if I use the precompiled ffi gem or install ffi via:

gem install ffi --platform ruby -- --disable-system-libffi --enable-libffi-alloc

I wonder if we can avoid the --disable-system-libffi by updating the Chef libffi to v3.4.8.

@tpowell-progress tpowell-progress self-assigned this Apr 15, 2025
@jaymzh
Copy link
Collaborator Author

jaymzh commented Apr 16, 2025

Calling @tpowell-progress on updating libffi in the omnibus build for macos.

@stanhu
Copy link
Contributor

stanhu commented Apr 16, 2025

Strangely I can't reproduce the macOS 13 failure this morning on a new VM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants