Skip to content

Instantly share code, notes, and snippets.

@Iristyle
Last active April 19, 2016 20:34
Show Gist options
  • Save Iristyle/05f796c3b5f036e9c435 to your computer and use it in GitHub Desktop.
Save Iristyle/05f796c3b5f036e9c435 to your computer and use it in GitHub Desktop.
Puppet Windbg testing
launching windbg
&'C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\windbg.exe' -g -G -Q -sflags 0x80030377 -y 'C:\Program Files\Puppet Labs\PuppetCustom\sys\ruby\bin'
&'C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\windbg.exe' -g -G -Q -sflags 0x80030377 -y 'bundle exec rspec .\spec\integration\provider\package_spec.rb'
&'C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\windbg.exe' -sflags 0x80030377 -g -y 'C:\Program Files\Puppet Labs\PuppetCustom\sys\ruby\bin' -z 'C:\source\20140806_131938_Hang_Mode-ruby_service\FULLDUMP_HangMode_ruby.exe__0b14_2014-08-06_13-19-38-710_08d4.dmp'
# -g (User mode only) Ignores the initial breakpoint in target application. This option will cause the target application to continue running after it is started or WinDbg attaches to it, unless another breakpoint has been set. See Initial Breakpoint for details.
# -G (User mode only) Ignores the final breakpoint at process termination. Typically, the debugging session ends during the image run-down process. This option will cause the debugging session to end immediately when the child terminates. This has the same effect as entering the command sxd epr. For more information, see Controlling Exceptions and Events.
# -Q Suppresses the "Save Workspace?" dialog box. Workspaces are not automatically saved. See Using Workspaces for details.
http://msdn.microsoft.com/en-us/library/windows/hardware/ff561306(v=vs.85).aspx
&'C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\windbg.exe' -g -G -Q
configuring gflags for a binary
# no need to use +hpa
# try with simpler "at end of process" check
&"C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\gflags.exe" /p /enable ruby.exe /leaks
# before moving on to this
&"C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\gflags.exe" /p /enable ruby.exe /full
&"C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\gflags.exe" /p /enable ruby.exe /leaks
gflags.exe /p /enable ruby.exe /full
## is functionally equiv to
## gflags.exe /i ruby.exe +hpa
## recommended to not use full page heap (above) with other debug-heap flags like +hfc +hpc
require 'puppet'
0:009> !heap -stat
_HEAP 000000003a650000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000004000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000007750000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 00000000051c0000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000004020000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000002e20000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000001c30000
Segments 00000001
Reserved bytes 0000000000100000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
0:009> !heap -s
LFH Key : 0x000000a267c35357
Termination on corruption : ENABLED
Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast
(k) (k) (k) (k) length blocks cont. heap
-------------------------------------------------------------------------------------
0000000002d20000 00000002 1024 8 1024 3 1 1 0 0
0000000003fa0000 00001002 512 8 512 3 1 1 0 0
0000000000010000 00008000 64 8 64 5 1 1 0 0
0000000000020000 00008000 2092 64 2092 61 1 1 0 0
00000000051b0000 00001002 64 8 64 3 1 1 0 0
0000000000350000 00001002 512 8 512 3 1 1 0 0
0000000008910000 00001002 512 8 512 3 1 1 0 0
00000000003f0000 00001002 64 16 64 11 1 1 0 0
-------------------------------------------------------------------------------------
0:009> !heap -l
Searching the memory for potential unreachable busy blocks.
Heap 0000000002d20000
Heap 0000000003fa0000
Heap 0000000000010000
Heap 0000000000020000
Heap 00000000051b0000
Heap 0000000000350000
Heap 0000000008910000
Heap 00000000003f0000
Scanning VM ...
Scanning references from 22 busy blocks (0 MBytes) ...No potential unreachable blocks were detected.
Puppet::Util::Windows::Process.get_environment_strings
0:009> !heap -stat
_HEAP 000000003a650000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000004000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000007750000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 00000000051c0000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000004020000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000002e20000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000001c30000
Segments 00000001
Reserved bytes 0000000000100000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
0:009> !heap -s
LFH Key : 0x000000a267c35357
Termination on corruption : ENABLED
Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast
(k) (k) (k) (k) length blocks cont. heap
-------------------------------------------------------------------------------------
0000000002d20000 00000002 1024 8 1024 3 1 1 0 0
0000000003fa0000 00001002 512 8 512 3 1 1 0 0
0000000000010000 00008000 64 8 64 5 1 1 0 0
0000000000020000 00008000 2092 64 2092 61 1 1 0 0
00000000051b0000 00001002 64 8 64 3 1 1 0 0
0000000000350000 00001002 512 8 512 3 1 1 0 0
0000000008910000 00001002 512 8 512 3 1 1 0 0
00000000003f0000 00001002 64 16 64 11 1 1 0 0
-------------------------------------------------------------------------------------
0:009> !heap -l
Searching the memory for potential unreachable busy blocks.
Heap 0000000002d20000
Heap 0000000003fa0000
Heap 0000000000010000
Heap 0000000000020000
Heap 00000000051b0000
Heap 0000000000350000
Heap 0000000008910000
Heap 00000000003f0000
Scanning VM ...
Scanning references from 22 busy blocks (0 MBytes) ...No potential unreachable blocks were detected.
0:009> g
(12e8.cc0): Break instruction exception - code 80000003 (first chance)
ntdll!DbgBreakPoint:
00000000`773ec690 cc int 3
0:002> !heap -stat
_HEAP 000000003a650000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000004000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000007750000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 00000000051c0000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000004020000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000002e20000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000001c30000
Segments 00000001
Reserved bytes 0000000000100000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
0:002> !heap -s
LFH Key : 0x000000a267c35357
Termination on corruption : ENABLED
Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast
(k) (k) (k) (k) length blocks cont. heap
-------------------------------------------------------------------------------------
0000000002d20000 00000002 1024 8 1024 3 1 1 0 0
0000000003fa0000 00001002 512 8 512 3 1 1 0 0
0000000000010000 00008000 64 8 64 5 1 1 0 0
0000000000020000 00008000 2092 64 2092 61 1 1 0 0
00000000051b0000 00001002 64 8 64 3 1 1 0 0
0000000000350000 00001002 512 8 512 3 1 1 0 0
0000000008910000 00001002 512 8 512 3 1 1 0 0
00000000003f0000 00001002 64 16 64 11 1 1 0 0
-------------------------------------------------------------------------------------
0:002> !heap -l
Searching the memory for potential unreachable busy blocks.
Heap 0000000002d20000
Heap 0000000003fa0000
Heap 0000000000010000
Heap 0000000000020000
Heap 00000000051b0000
Heap 0000000000350000
Heap 0000000008910000
Heap 00000000003f0000
Scanning VM ...
Scanning references from 22 busy blocks (0 MBytes) ...No potential unreachable blocks were detected.
provider = Puppet::Type.type(:package).provider(:gem)
options = {:name => "nosuchgem", :provider => provider.name}
pkg = Puppet::Type.newpackage(options)
irb(main):003:0> provider = Puppet::Type.type(:package).provider(:gem)
=> Puppet::Type::Package::ProviderGem
irb(main):004:0> options = {:name => "nosuchgem", :provider => provider.name}
=> {:name=>"nosuchgem", :provider=>:gem}
irb(main):005:0> pkg = Puppet::Type.newpackage(options)
SystemStackError: stack level too deep
from C:/tools/ruby21/lib/ruby/2.1.0/irb/inspector.rb:122
Maybe IRB bug!
0:010> !heap -stat
_HEAP 000000003a650000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000004000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000007750000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 00000000051c0000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000004020000
Segments 00000001
Reserved bytes 0000000000010000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000002e20000
Segments 00000001
Reserved bytes 0000000000080000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
_HEAP 0000000001c30000
Segments 00000001
Reserved bytes 0000000000100000
Committed bytes 0000000000002000
VirtAllocBlocks 00000000
VirtAlloc bytes 0000000000000000
0:010> !heap -s
LFH Key : 0x000000a267c35357
Termination on corruption : ENABLED
Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast
(k) (k) (k) (k) length blocks cont. heap
-------------------------------------------------------------------------------------
0000000002d20000 00000002 1024 8 1024 3 1 1 0 0
0000000003fa0000 00001002 512 8 512 3 1 1 0 0
0000000000010000 00008000 64 8 64 5 1 1 0 0
0000000000020000 00008000 2092 64 2092 61 1 1 0 0
00000000051b0000 00001002 64 8 64 3 1 1 0 0
0000000000350000 00001002 512 8 512 3 1 1 0 0
0000000008910000 00001002 512 8 512 3 1 1 0 0
00000000003f0000 00001002 64 16 64 11 1 1 0 0
-------------------------------------------------------------------------------------
0:010> !heap -l
Searching the memory for potential unreachable busy blocks.
Heap 0000000002d20000
Heap 0000000003fa0000
Heap 0000000000010000
Heap 0000000000020000
Heap 00000000051b0000
Heap 0000000000350000
Heap 0000000008910000
Heap 00000000003f0000
Scanning VM ...
Scanning references from 22 busy blocks (0 MBytes) ...No potential unreachable blocks were detected.
===============================================================================
RESTART - run specs
===============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment