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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • 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
    • Component/s: Windows
    • Labels:
      None
    • 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:
      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).
    • 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.

        Attachments

        1. seg.txt
          104 kB
          Thomas Kishel

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support