Jira (PUP-10150) Puppet Stack Trace is cleared before exception handlers can query it

12 views
Skip to first unread message

Glenn Sarti (JIRA)

unread,
Nov 21, 2019, 9:02:34 AM11/21/19
to puppe...@googlegroups.com
Glenn Sarti created an issue
 
Puppet / Bug PUP-10150
Puppet Stack Trace is cleared before exception handlers can query it
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2019/11/21 6:01 AM
Priority: Normal Normal
Reporter: Glenn Sarti

Puppet Version: 6.11.1
Puppet Server Version: N/A
OS Name/Version: Windows 10

As part of https://github.com/puppetlabs/puppet/pull/7754 the Puppet Stack Trace feature was modified to use an independent stack trace storing mechanism, however this may have introduced an unforseen behaviour change.

Previously users would be able to trace how Puppet has traversed the invocations within a Manifest file. For example int the given manifest

class nest1 {
  fail('somethinng')
}
 
class nest2 {
  include nest1
}
 
include nest2

Previously in Puppet 6.10.1, we can see a puppet apply <manifest> --trace gives

Error: Evaluation Error: Error while evaluating a Function Call, somethinng (file: C:/Source/puppet/tmp/test.pp, line: 2, column: 3) on node glenn.sarti-r90qu2hx
C:/Source/puppet/lib/puppet/parser/functions/fail.rb:10:in `block in get_binding'
C:/Source/puppet/lib/puppet/parser/functions.rb:206:in `block (2 levels) in newfunction'
...
C:/Source/puppet/tmp/test.pp:2:in `block in call_function'
...
C:/Source/puppet/tmp/test.pp:6:in `block in call_function'
...
C:/Source/puppet/tmp/test.pp:9:in `block in call_function'
...
C:/Source/puppet/tmp/test.pp:in `stack'
...

We can see the various includes and Puppet call stack.

However in Puppet 6.11.1 we get:

...
Error: Evaluation Error: Error while evaluating a Function Call, somethinng (file: C:/Source/puppet/tmp/test.pp, line: 2, column: 3) on node glenn.sarti-r90qu2hx

And that's it. The call stack within Puppet is no longer available. Now, that's probably due to Puppet no longer using the Ruby stack to store the information, however...

Due to the way the stack is implemented, the stack is cleared (via the `shift` in https://github.com/puppetlabs/puppet/blob/1356f58d66/lib/puppet/pops/puppet_stack.rb#L44-L46) BEFORE any error trapping can occur.

Effectively, the Puppet Stack is no longer available during exceptions, only the exception location, which seems a concerning.

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

Justin Stoller (JIRA)

unread,
Nov 21, 2019, 11:37:03 AM11/21/19
to puppe...@googlegroups.com
Justin Stoller commented on Bug PUP-10150
 
Re: Puppet Stack Trace is cleared before exception handlers can query it

One thing that I wasn't clear from the description, there still is a ruby stack trace with `--trace`, right. ie, this is what I see on master:

puppet (master *$%<>) :: be puppet apply broken.pp --trace                                                                                                     
Warning: Facter: Could not find a default route. Using first non-loopback interface         
Error: Evaluation Error: Error while evaluating a Function Call, somethinng (file: /Users/justin/Backup/code/work/puppet/broken.pp, line: 3, column: 3) on node 
localhost                                                                                                                                                       
/Users/justin/Backup/code/work/puppet/lib/puppet/parser/functions/fail.rb:10:in `block in get_binding'                  
/Users/justin/Backup/code/work/puppet/lib/puppet/parser/functions.rb:206:in `block (2 levels) in newfunction'
/Users/justin/Backup/code/work/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'         
/Users/justin/Backup/code/work/puppet/lib/puppet/util/profiler.rb:51:in `profile'                                  
/Users/justin/Backup/code/work/puppet/lib/puppet/parser/functions.rb:199:in `block in newfunction'                         
/Users/justin/Backup/code/work/puppet/lib/puppet/functions.rb:751:in `block in call'                                                                            
/Users/justin/Backup/code/work/puppet/lib/puppet/functions.rb:748:in `catch'                                                                                    
/Users/justin/Backup/code/work/puppet/lib/puppet/functions.rb:748:in `call'                                                                                     
/Users/justin/Backup/code/work/puppet/lib/puppet/pops/puppet_stack.rb:42:in `stack'               <-- this would have been /Users/justin/Backup/code/work/puppet/broken.pp:6
/Users/justin/Backup/code/work/puppet/lib/puppet/pops/evaluator/runtime3_support.rb:305:in `block in call_function'

Justin Stoller (JIRA)

unread,
Nov 21, 2019, 12:09:04 PM11/21/19
to puppe...@googlegroups.com

Would it be valuable to print the puppet stack as its own trace, or is it the interleaving of them with the ruby code valuable? (Or are there use cases for both?)

Justin Stoller (JIRA)

unread,
Nov 21, 2019, 12:29:03 PM11/21/19
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Nov 21, 2019, 1:08:04 PM11/21/19
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-10150
 
Re: Puppet Stack Trace is cleared before exception handlers can query it

Justin Stoller The interleaving is of value for someone on a deep bug hunt in Ruby if/when you want to see both where you ended up and how you got there via intermediate Ruby. This was of value to me when working on some evaluator / call stuff. For puppet users and the typical use of the puppet stack there is no value in the interleaving (they always see the filtered result anyway). However, as you point out, when there is an exception and the ruby stack is dumped out - when things were interleaved you got both at the same time - which sometimes is of value when reporting an issue. Doubt that most puppet users manage to interpret what they are looking at (i.e. won't see the interleaves puppet things, or don't know how to use that).

For puppet users, the puppet stack is probably of more value (to find their problems in their code).

A thought; not interleaving makes it possible to add information that could not be represented in the Ruby stack - for example also recording the position on the line (i.e. to differentiate between several calls on the same line) if we ever want to do that.

Charlie Sharpsteen (JIRA)

unread,
Nov 21, 2019, 1:26:05 PM11/21/19
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages