[FACT-1936] facter -p segfaults with facts that call open-uri.open Created: 2019/07/11  Updated: 2019/09/12  Resolved: 2019/08/12

Status: Resolved
Project: Facter
Component/s: Windows
Affects Version/s: FACT 3.12.5, FACT 3.13.3, FACT 3.14.2
Fix Version/s: FACT 3.12.z, FACT 3.13.z

Type: Bug Priority: Normal
Reporter: Thomas Kishel Assignee: Gabriel Nagy
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File seg.txt    
Issue Links:
Problem/Incident
is caused by LTH-163 Call ruby_sysinit to initialize Windo... Resolved
Relates
Template:
Team: Night's Watch
Story Points: 5
Sprint: NW - 2019-08-07, NW - 2019-08-21
Method Found: Needs Assessment
Release Notes: Not Needed
Release Notes Summary: Ruby versions starting with 2.5 have changed how the Windows sockets are started, requiring a call to an additional function for starting them.

Not having this call causes segmentation faults when querying custom facts that use Windows Sockets with Ruby versions 2.5 and higher (i.e. custom facts that make HTTP requests).
QA Risk Assessment: Needs Assessment

 Description   

Puppet Version: 6.0.9
Facter Version: 3.12.4 (commit ce9452fd2d15ed91eed9b8cc7823af783c9275a8)
OS Name/Version: Windows 2012

This custom fact succeeds on Linux but segfaults on Windows ... but only when calling facter -p not with puppet facts or puppet agent -t

require 'open-uri'
require 'json'
require 'timeout'
 
Facter.add('test') do
  response = nil
  begin
    url = 'https://api.ipify.org?format=json'
    Timeout::timeout(4) do
      response = open(url).read
    end
  rescue
    nil
  end
  if !response.to_s.empty?
    result = JSON.parse(response)
    setcode do
      result['ip']
    end
  end
end

(Same segfault occurs if you use Net::HTTP.get(URI.parse('https://api.ipify.org?format=json')) instead of open(url).read)

Result attached.



 Comments   
Comment by Jean Bond [ 2019/09/11 ]

I just happened upon this ticket while researching another one; can anyone let me know what version of Facter this went into? No release note has been published for it because there isn't a specific fix version on it.

Comment by Gabriel Nagy [ 2019/09/12 ]

Jean Bond the investigation for this ticket was done on Facter, but the fix was actually on a different project (Leatherman / LTH-163) - which is a dependency, so I'm not sure this should have fix versions on Facter.

Comment by Jean Bond [ 2019/09/12 ]

Fair enough Gabriel Nagy. It's my mistake anyway, because the docs tab clearly says "not needed". Apologies for the noise!

Generated at Sat Aug 08 08:02:08 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.