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

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

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