Uploaded image for project: 'Facter'
  1. Facter
  2. FACT-1936

facter -p segfaults with facts that call open-uri.open

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • FACT 3.12.5, FACT 3.13.3, FACT 3.14.2
    • FACT 3.12.z, FACT 3.13.z
    • Windows
    • None
    • Night's Watch
    • 5
    • NW - 2019-08-07, NW - 2019-08-21
    • Needs Assessment
    • Not Needed
    • Hide
      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).
      Show
      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).
    • 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.

      Attachments

        Issue Links

          Activity

            People

              gabriel.nagy Gabriel Nagy
              tom.kishel Thomas Kishel
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support