Jira (FACT-1936) facter -p segfaults with facts that call open-uri.open

0 views
Skip to first unread message

Thomas Kishel (JIRA)

unread,
Jul 11, 2019, 3:24:04 PM7/11/19
to puppe...@googlegroups.com
Thomas Kishel created an issue
 
Facter / Bug FACT-1936
facter -p segfaults with facts that call open-uri.open
Issue Type: Bug Bug
Assignee: Unassigned
Components: Windows
Created: 2019/07/11 12:23 PM
Priority: Normal Normal
Reporter: Thomas Kishel

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

C:\Users\Administrator>facter -p                                                                                                                                          
C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/net/protocol.rb:45: [BUG] Segmentation fault                                                                    
ruby 2.5.3p105 (2018-10-18 revision 65156) [x64-mingw32]                                                                                                                  
                                                                                                                                                                          
-- Control frame information -----------------------------------------------                                                                                              
c:0082 p:---- s:0522 e:000521 CFUNC  :wait_readable                                                                                                                       
c:0081 p:0093 s:0517 e:000516 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/net/protocol.rb:45                                                         
c:0080 p:0557 s:0510 E:002178 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/net/http.rb:981                                                            
c:0079 p:0004 s:0497 e:000496 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/net/http.rb:920                                                            
c:0078 p:0029 s:0493 e:000492 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/net/http.rb:909                                                            
c:0077 p:0521 s:0489 e:000488 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/open-uri.rb:337                                                            
c:0076 p:0017 s:0468 e:000467 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/open-uri.rb:755                                                            
c:0075 p:0029 s:0461 e:000460 BLOCK  C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/open-uri.rb:226 [FINISH]                                                   
c:0074 p:---- s:0458 e:000457 CFUNC  :catch                                                                                                                               
c:0073 p:0365 s:0453 E:001398 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/open-uri.rb:224                                                            
c:0072 p:0328 s:0438 e:000437 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/open-uri.rb:165                                                            
c:0071 p:0018 s:0426 e:000425 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/open-uri.rb:735                                                            
c:0070 p:0071 s:0420 e:000419 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/open-uri.rb:35                                                             
c:0069 p:0007 s:0412 e:000411 BLOCK  C:/ProgramData/PuppetLabs/puppet/cache/lib/facter/test.rb:11                                                                         
c:0068 p:0030 s:0409 E:002298 BLOCK  C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/timeout.rb:93                                                              
c:0067 p:0005 s:0403 e:000402 BLOCK  C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/timeout.rb:33 [FINISH]                                                     
c:0066 p:---- s:0400 e:000399 CFUNC  :catch                                                                                                                               
c:0065 p:0044 s:0395 e:000394 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/timeout.rb:33                                                              
c:0064 p:0113 s:0389 E:001da0 METHOD C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/timeout.rb:108                                                             
c:0063 p:0021 s:0377 E:001ed8 BLOCK  C:/ProgramData/PuppetLabs/puppet/cache/lib/facter/test.rb:10 [FINISH]                                                                
c:0062 p:---- s:0371 e:000370 CFUNC  :instance_eval                                                                                                                       
c:0061 p:---- s:0368 e:000367 CFUNC  :add                                                                                                                                 
c:0060 p:0034 s:0363 E:000720 TOP    C:/ProgramData/PuppetLabs/puppet/cache/lib/facter/test.rb:5 [FINISH]                                                                 
c:0059 p:---- s:0360 e:000359 CFUNC  :value 

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

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Thomas Kishel (JIRA)

unread,
Jul 11, 2019, 3:31:02 PM7/11/19
to puppe...@googlegroups.com
Thomas Kishel updated an issue
Change By: Thomas Kishel
*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}}



{code}

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
{code}

{code}

C:\Users\Administrator>facter -p                    
C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.5.0/net/protocol.rb:45: [BUG] Segmentation fault                    
ruby 2.5.3p105 ( 2018-10-18 revision 65156) [x64-mingw32]                    
{code}

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

Result attached.

Thomas Kishel (JIRA)

unread,
Jul 11, 2019, 3:31:03 PM7/11/19
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Jul 16, 2019, 10:14:03 AM7/16/19
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Jul 16, 2019, 10:14:04 AM7/16/19
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Jul 24, 2019, 5:30:02 AM7/24/19
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Jul 24, 2019, 5:30:03 AM7/24/19
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: PR NW - Triage 2019-08-07

Gabriel Nagy (JIRA)

unread,
Jul 29, 2019, 4:46:04 AM7/29/19
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Aug 7, 2019, 4:38:09 AM8/7/19
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2019-08-07 , NW - 2019-08-21

Gabriel Nagy (JIRA)

unread,
Aug 13, 2019, 2:42:03 AM8/13/19
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Fix Version/s: FACT 3.13.z
Fix Version/s: FACT 3.12.z

Gabriel Nagy (JIRA)

unread,
Aug 13, 2019, 2:42:03 AM8/13/19
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Affects Version/s: FACT 3.14.2
Affects Version/s: FACT 3.13.3
Affects Version/s: FACT 3.12.5

Gabriel Nagy (JIRA)

unread,
Aug 14, 2019, 4:31:03 AM8/14/19
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Release Notes: Bug Fix Not Needed

Jean Bond (JIRA)

unread,
Sep 11, 2019, 5:07:03 PM9/11/19
to puppe...@googlegroups.com
Jean Bond commented on Bug FACT-1936
 
Re: facter -p segfaults with facts that call open-uri.open

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.

Gabriel Nagy (JIRA)

unread,
Sep 12, 2019, 6:07:03 AM9/12/19
to puppe...@googlegroups.com
Gabriel Nagy commented on Bug FACT-1936

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.

Jean Bond (JIRA)

unread,
Sep 12, 2019, 11:19:04 AM9/12/19
to puppe...@googlegroups.com
Jean Bond commented on Bug FACT-1936

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

Reply all
Reply to author
Forward
0 new messages