SlideShare a Scribd company logo
1 of 14
Download to read offline
How to inspect
RUNNING perl process
@hirose31
ひろせ まさあき
YAPC::Asia Tokyo 2013
LT Day 1
Who am I
•PAUSE ID: HIROSE / @hirose31
•Recognize as NON-human on CPAN
テキスト
https://metacpan.org/module/Acme::CPANAuthors::Nonhuman
Agenda
How to inspect a RUNNING perl process
•Motivation
•Revisit existing ideas
•Introduce a my idea
Motivation
•WHY: shooting trouble of RUNNING perl
process
•examine where perl process is running
•where does process hang up?
•where does process loop forever?
•which pacage leaks memory?
•want to examine from OUTER without
editing target process/script
Revisit existing ideas
‘strace’
• strace -fF -Tttt -s 512 -p PID
• current system call
• show the time spent in system calls
• peep into an ASCII string
• no requires☺, just attach process
• show just name of system call not perl symbol☹
1379392067.757575 accept(5,
1379392038.406593 write(5, "220003 select
sleep(8) ", 22) = 22 <0.000083>
1379392038.406791 read(5,
Revisit existing ideas
‘gdb’
• Attach and trace code by gdb
• Generate a core file by gcore PID
• “Introduction gdb to perl programmers”, @stanaka,
Shibuya.pm #9
http://blog.stanaka.org/entry/20080630/1214780557
• show stacktrace with perl symbol
#0 0x00007fb086990c20 in __accept_nocancel () from /lib/
libpthread.so.0
#1 0x00000000004f19e8 in Perl_pp_accept (my_perl=0xd69010) at
pp_sys.c:2554
...
#5 0x0000000000420eef in main (argc=8, argv=0x7fff34899828,
env=0x7fff34899870) at perlmain.c:99
Revisit existing ideas
‘bulkdbg’
•https://github.com/ahiguti/bulkdbg
•bulkdbg PID
•show stackstrace with perl symbol
•convinient by batch
3183
__accept_nocancel:Perl_pp_accept:Perl_pop_scope:Perl_peep:_dl_r
tld_di_serinfo:PerlIO_debug:_dl_rtld_di_serinfo:PerlIO_debug:ca
lloc:calloc:__libc_malloc:calloc:_dl_rtld_di_serinfo:S_hv_fetch
_common
Revisit existing ideas
‘gdbperl’
• https://github.com/ahiguti/gdbperl
• examine state of perl interpreter using gdb
• “debugging Perl script with gdb”, Akira Higuchi, YAPC::Asia Tokyo
2011
http://www.slideshare.net/akirahiguchi/gdbperl
• show stacktrace with perl code☺, package name, line number!!
• depend heavily on perl version/internal structure☹
perl_backtrace:
[8] IO::Socket::accept() <- /.../perl-5.8.8-threads/lib/
site_perl/5.8.8/Starlet/Server.pm:106(Starlet::Server)
[7] (loop) <- /.../perl-5.8.8-threads/lib/site_perl/5.8.8/
Starlet/Server.pm:105(Starlet::Server)
...
[1] Plack::Runner::run() <- /.../perl-5.8.8-threads/bin/
plackup:10(main)
Introduce a my idea
‘inspect-perl-proc’
• https://github.com/hirose31/inspect-perl-proc
• Attach by gdb and run arbitrary Perl code
using Perl_eval_pv
• less requires: gdb, perl with debug symbol (-
DDEBUGGING=-g)
• not depend on perl version / perl internal
structure
• save output to file, not output STDOUT/
STDERR of target process
dump-perl-stacktrace
• dump-perl-stacktrace
= inspect-perl-proc --mode 'dump-stacktrace'
• Carp::longmess(‘Dump stacktrace’)
Dump stacktrace at /.../perl-5.8.8-threads/lib/5.8.8/x86_64-
linux-thread-multi/IO/Socket.pm line 237
IO::Socket::accept('IO::Socket::INET=GLOB()')
called at /.../Starlet/Server.pm line 106
Starlet::Server::accept_loop('Plack::Handler::
Starlet=HASH()', 'CODE()', 100) called
at /.../Starlet.pm line 67
Plack::Handler::Starlet::run('Plack::Handler::
Starlet=HASH()', 'CODE()') called
at /.../Plack/Loader.pm line 84
...
Plack::Runner::run('Plack::Runner=HASH()') called
at /.../bin/plackup line 10
dump-perl-memusage
• dump-perl-memusage
= inspect-perl-proc --mode 'dump-memusage'
• Dump memory usage with B::Size2::Terse::package_size
for each packages (Devel::Symdump)
• save as as hashref so you can filter or sort easily
{
'main' => '95589',
...
'PerlIO::scalar' => '1025',
'Plack' => '3056',
'Plack::App' => '200',
'Plack::App::URLMap' => '26681',
'Plack::Builder' => '31972',
...
};
dump-perl-inc
• dump-perl-inc
= inspect-perl-proc --mode 'dump-inc'
• Dump %INC
• list up loaded modules for preloading (CoW)
• save as as hashref so you can filter or sort easily
{
'parent.pm' => '/.../parent.pm',
'HTTP/Status.pm' => '/.../HTTP/Status.pm',
'POSIX.pm' => '/.../POSIX.pm',
'List/Util.pm' => '/.../List/Util.pm',
'Plack/Loader.pm' => '/.../Plack/Loader.pm',
'Cwd.pm' => '/.../Cwd.pm',
'Fcntl.pm' => '/.../Fcntl.pm',
...
};
Introduce a my idea
‘inspect-perl-proc’
• https://github.com/hirose31/inspect-perl-proc
• Attach by gdb and run arbitrary code using
Perl_eval_pv
• less requires: gdb, perl with debug symbol (-
DDEBUGGING=-g)
• not depend on perl version / perl internal
structure
• save output to file, not output STDOUT/
STDERR of target process
Thanks :D

More Related Content

What's hot

Perl Memory Use 201209
Perl Memory Use 201209Perl Memory Use 201209
Perl Memory Use 201209Tim Bunce
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)charsbar
 
HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)
HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)
HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)Ontico
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0Tim Bunce
 
Shellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and ConceptShellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and ConceptJulia Yu-Chin Cheng
 
"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"Badoo Development
 
Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Tim Bunce
 
Top 10 Perl Performance Tips
Top 10 Perl Performance TipsTop 10 Perl Performance Tips
Top 10 Perl Performance TipsPerrin Harkins
 
Profiling with Devel::NYTProf
Profiling with Devel::NYTProfProfiling with Devel::NYTProf
Profiling with Devel::NYTProfbobcatfish
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12Tim Bunce
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4Wim Godden
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Tim Bunce
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to productionSean Hess
 
台科逆向簡報
台科逆向簡報台科逆向簡報
台科逆向簡報耀德 蔡
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)julien pauli
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5julien pauli
 
Jersey framework
Jersey frameworkJersey framework
Jersey frameworkknight1128
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and coPierre Joye
 

What's hot (20)

Perl Memory Use 201209
Perl Memory Use 201209Perl Memory Use 201209
Perl Memory Use 201209
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)
 
HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)
HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)
HHVM: Efficient and Scalable PHP/Hack Execution / Guilherme Ottoni (Facebook)
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0
 
Shellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and ConceptShellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and Concept
 
"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"
 
Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406
 
Top 10 Perl Performance Tips
Top 10 Perl Performance TipsTop 10 Perl Performance Tips
Top 10 Perl Performance Tips
 
Profiling with Devel::NYTProf
Profiling with Devel::NYTProfProfiling with Devel::NYTProf
Profiling with Devel::NYTProf
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
 
台科逆向簡報
台科逆向簡報台科逆向簡報
台科逆向簡報
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5
 
Jersey framework
Jersey frameworkJersey framework
Jersey framework
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 
x86
x86x86
x86
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
 

Similar to How to inspect a RUNNING perl process

Systems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesSystems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesHelpWithAssignment.com
 
JProfiler8 @ OVIRT
JProfiler8 @ OVIRTJProfiler8 @ OVIRT
JProfiler8 @ OVIRTLiran Zelkha
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...Yury Bushmelev
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNoSuchCon
 
Lightweight static code analysis with semgrep
Lightweight static code analysis with semgrepLightweight static code analysis with semgrep
Lightweight static code analysis with semgrepNull Bhubaneswar
 
Taking Hunting to the Next Level: Hunting in Memory
Taking Hunting to the Next Level: Hunting in MemoryTaking Hunting to the Next Level: Hunting in Memory
Taking Hunting to the Next Level: Hunting in MemoryJoe Desimone
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)goccy
 
plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6Nobuo Danjou
 
No locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureNo locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureAndrew Petukhov
 
04_ForkPipe.pptx
04_ForkPipe.pptx04_ForkPipe.pptx
04_ForkPipe.pptxvnwzympx
 
Lateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your NetworkLateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your NetworkEC-Council
 
Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016Xavier Ashe
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM ProfilingAndrei Pangin
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance毅 吕
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshopDamien Seguy
 

Similar to How to inspect a RUNNING perl process (20)

Systems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesSystems Programming Assignment Help - Processes
Systems Programming Assignment Help - Processes
 
JProfiler8 @ OVIRT
JProfiler8 @ OVIRTJProfiler8 @ OVIRT
JProfiler8 @ OVIRT
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
Lightweight static code analysis with semgrep
Lightweight static code analysis with semgrepLightweight static code analysis with semgrep
Lightweight static code analysis with semgrep
 
Taking Hunting to the Next Level: Hunting in Memory
Taking Hunting to the Next Level: Hunting in MemoryTaking Hunting to the Next Level: Hunting in Memory
Taking Hunting to the Next Level: Hunting in Memory
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
PHP Profiling/performance
PHP Profiling/performancePHP Profiling/performance
PHP Profiling/performance
 
plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6
 
No locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureNo locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructure
 
04_ForkPipe.pptx
04_ForkPipe.pptx04_ForkPipe.pptx
04_ForkPipe.pptx
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
 
Lateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your NetworkLateral Movement: How attackers quietly traverse your Network
Lateral Movement: How attackers quietly traverse your Network
 
Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016Lateral Movement - Hacker Halted 2016
Lateral Movement - Hacker Halted 2016
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 

More from Masaaki HIROSE

Redunduncy of NAT instance on AWS/VPC
Redunduncy of NAT instance on AWS/VPCRedunduncy of NAT instance on AWS/VPC
Redunduncy of NAT instance on AWS/VPCMasaaki HIROSE
 
Introduction of aws-cli
Introduction of aws-cliIntroduction of aws-cli
Introduction of aws-cliMasaaki HIROSE
 
『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラMasaaki HIROSE
 
Shibuya.pm #9 My First XS
Shibuya.pm #9 My First XSShibuya.pm #9 My First XS
Shibuya.pm #9 My First XSMasaaki HIROSE
 

More from Masaaki HIROSE (6)

JVM! JVM! JVM!
JVM! JVM! JVM!JVM! JVM! JVM!
JVM! JVM! JVM!
 
Redunduncy of NAT instance on AWS/VPC
Redunduncy of NAT instance on AWS/VPCRedunduncy of NAT instance on AWS/VPC
Redunduncy of NAT instance on AWS/VPC
 
Introduction of aws-cli
Introduction of aws-cliIntroduction of aws-cli
Introduction of aws-cli
 
『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ
 
Shibuya.pm #9 My First XS
Shibuya.pm #9 My First XSShibuya.pm #9 My First XS
Shibuya.pm #9 My First XS
 
Aio
AioAio
Aio
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

How to inspect a RUNNING perl process

  • 1. How to inspect RUNNING perl process @hirose31 ひろせ まさあき YAPC::Asia Tokyo 2013 LT Day 1
  • 2. Who am I •PAUSE ID: HIROSE / @hirose31 •Recognize as NON-human on CPAN テキスト https://metacpan.org/module/Acme::CPANAuthors::Nonhuman
  • 3. Agenda How to inspect a RUNNING perl process •Motivation •Revisit existing ideas •Introduce a my idea
  • 4. Motivation •WHY: shooting trouble of RUNNING perl process •examine where perl process is running •where does process hang up? •where does process loop forever? •which pacage leaks memory? •want to examine from OUTER without editing target process/script
  • 5. Revisit existing ideas ‘strace’ • strace -fF -Tttt -s 512 -p PID • current system call • show the time spent in system calls • peep into an ASCII string • no requires☺, just attach process • show just name of system call not perl symbol☹ 1379392067.757575 accept(5, 1379392038.406593 write(5, "220003 select sleep(8) ", 22) = 22 <0.000083> 1379392038.406791 read(5,
  • 6. Revisit existing ideas ‘gdb’ • Attach and trace code by gdb • Generate a core file by gcore PID • “Introduction gdb to perl programmers”, @stanaka, Shibuya.pm #9 http://blog.stanaka.org/entry/20080630/1214780557 • show stacktrace with perl symbol #0 0x00007fb086990c20 in __accept_nocancel () from /lib/ libpthread.so.0 #1 0x00000000004f19e8 in Perl_pp_accept (my_perl=0xd69010) at pp_sys.c:2554 ... #5 0x0000000000420eef in main (argc=8, argv=0x7fff34899828, env=0x7fff34899870) at perlmain.c:99
  • 7. Revisit existing ideas ‘bulkdbg’ •https://github.com/ahiguti/bulkdbg •bulkdbg PID •show stackstrace with perl symbol •convinient by batch 3183 __accept_nocancel:Perl_pp_accept:Perl_pop_scope:Perl_peep:_dl_r tld_di_serinfo:PerlIO_debug:_dl_rtld_di_serinfo:PerlIO_debug:ca lloc:calloc:__libc_malloc:calloc:_dl_rtld_di_serinfo:S_hv_fetch _common
  • 8. Revisit existing ideas ‘gdbperl’ • https://github.com/ahiguti/gdbperl • examine state of perl interpreter using gdb • “debugging Perl script with gdb”, Akira Higuchi, YAPC::Asia Tokyo 2011 http://www.slideshare.net/akirahiguchi/gdbperl • show stacktrace with perl code☺, package name, line number!! • depend heavily on perl version/internal structure☹ perl_backtrace: [8] IO::Socket::accept() <- /.../perl-5.8.8-threads/lib/ site_perl/5.8.8/Starlet/Server.pm:106(Starlet::Server) [7] (loop) <- /.../perl-5.8.8-threads/lib/site_perl/5.8.8/ Starlet/Server.pm:105(Starlet::Server) ... [1] Plack::Runner::run() <- /.../perl-5.8.8-threads/bin/ plackup:10(main)
  • 9. Introduce a my idea ‘inspect-perl-proc’ • https://github.com/hirose31/inspect-perl-proc • Attach by gdb and run arbitrary Perl code using Perl_eval_pv • less requires: gdb, perl with debug symbol (- DDEBUGGING=-g) • not depend on perl version / perl internal structure • save output to file, not output STDOUT/ STDERR of target process
  • 10. dump-perl-stacktrace • dump-perl-stacktrace = inspect-perl-proc --mode 'dump-stacktrace' • Carp::longmess(‘Dump stacktrace’) Dump stacktrace at /.../perl-5.8.8-threads/lib/5.8.8/x86_64- linux-thread-multi/IO/Socket.pm line 237 IO::Socket::accept('IO::Socket::INET=GLOB()') called at /.../Starlet/Server.pm line 106 Starlet::Server::accept_loop('Plack::Handler:: Starlet=HASH()', 'CODE()', 100) called at /.../Starlet.pm line 67 Plack::Handler::Starlet::run('Plack::Handler:: Starlet=HASH()', 'CODE()') called at /.../Plack/Loader.pm line 84 ... Plack::Runner::run('Plack::Runner=HASH()') called at /.../bin/plackup line 10
  • 11. dump-perl-memusage • dump-perl-memusage = inspect-perl-proc --mode 'dump-memusage' • Dump memory usage with B::Size2::Terse::package_size for each packages (Devel::Symdump) • save as as hashref so you can filter or sort easily { 'main' => '95589', ... 'PerlIO::scalar' => '1025', 'Plack' => '3056', 'Plack::App' => '200', 'Plack::App::URLMap' => '26681', 'Plack::Builder' => '31972', ... };
  • 12. dump-perl-inc • dump-perl-inc = inspect-perl-proc --mode 'dump-inc' • Dump %INC • list up loaded modules for preloading (CoW) • save as as hashref so you can filter or sort easily { 'parent.pm' => '/.../parent.pm', 'HTTP/Status.pm' => '/.../HTTP/Status.pm', 'POSIX.pm' => '/.../POSIX.pm', 'List/Util.pm' => '/.../List/Util.pm', 'Plack/Loader.pm' => '/.../Plack/Loader.pm', 'Cwd.pm' => '/.../Cwd.pm', 'Fcntl.pm' => '/.../Fcntl.pm', ... };
  • 13. Introduce a my idea ‘inspect-perl-proc’ • https://github.com/hirose31/inspect-perl-proc • Attach by gdb and run arbitrary code using Perl_eval_pv • less requires: gdb, perl with debug symbol (- DDEBUGGING=-g) • not depend on perl version / perl internal structure • save output to file, not output STDOUT/ STDERR of target process