SlideShare a Scribd company logo
1 of 18
Download to read offline
Global Destruction
Thursday, May 8, 14
in 5 minutes
There’s another talk:
Global Destruction
in 20 Minutes
Thursday, May 8, 14
What is global
destruction?
Thursday, May 8, 14
What is global
destruction?
• Perl has a couple of run-time phases:
BEGIN, CHECK, UNITCHECK, INIT,
runloop, END, DESTRUCT
• perldoc perlmod
Thursday, May 8, 14
What is global
destruction?
• BEGIN, CHECK, UNITCHECK, INIT,
runloop, END, DESTRUCT
• DESTRUCT cannot be called by
DESTRUCT {} blocks.
Thursday, May 8, 14
What is global
destruction?
• BEGIN, CHECK, UNITCHECK, INIT,
runloop, END, DESTRUCT
• DESTRUCT cannot be called by
DESTRUCT {} blocks.
• the runloop neither
Thursday, May 8, 14
DESTRUCT
• DESTRUCT is executed after
PerlIO_destruct and before PerlIO_clean
• DESTRUCT calls DESTROY methods on all
objects which do have a DESTROY method
(sv_clean_obj)
Thursday, May 8, 14
package FINALE;
{
$ref3 = bless ["ok - package destruction"];
my $ref2 = bless ["ok - lexical destructionn"];
local $ref1 = bless ["ok - dynamic destructionn"];
1;
}
DESTROY {
print $_[0][0];
}
DEMO t/testc.sh -A -O3 -k 197
DESTRUCT
Thursday, May 8, 14
DESTRUCT
• Beware! Our current perlcc compiler does
not do global destruction.
• 2nd warning: our variables behave like
globals! Use only my, not our
Thursday, May 8, 14
package FINALE;
{
$ref3 = bless ["ok - package destructionn"];
my $ref2 = bless ["ok - lexical destructionn"];
our $ref4 = bless ["ok - our destructionn"];
local $ref1 = bless ["ok - dynamic destructionn"];
1;
}
DESTROY {
print $_[0][0];
}
=>
ok - dynamic destruction
ok - lexical destruction
ok - package destruction
ok - our destruction
DESTRUCT
Thursday, May 8, 14
perl debugging: -DD (-D? => D Cleaning up)
$ ./ccode197_o3 -DD
EXECUTING...
ok - dynamic destruction
ok - lexical destruction
Cursing named global static sv_arena:
Calling FINALE::DESTROY
ok - package destruction
sv_arena: 0x7ff9b982f600 - 0x7ff9b98305f0 (170)
sv_arena: 0x7ff9b982ae00 - 0x7ff9b982bdf0 (170)
sv_arena: 0x7ff9b9807800 - 0x7ff9b98087f0 (170)
Cleaning named glob IO object:
SV = PVIO(0x7ff9b982ce00) at 0x7ff9b982b7a8
REFCNT = 2
FLAGS = (OBJECT)
STASH = 0x7ff9b982b268! "IO::File"
...
DESTRUCT
Thursday, May 8, 14
ok - dynamic destruction
ok - lexical destruction
Cursing named global static sv_arena:
Calling FINALE::DESTROY
ok - package destruction
Cleaning object ref:
SV = IV(0x10076dce8) at 0x10076dcf8
REFCNT = 1
FLAGS = (ROK)
RV = 0x7fc549802aa8
SV = PVAV(0x7fc549005530) at 0x7fc549802aa8
FLAGS = (OBJECT)
STASH = 0x7fc5490287f8! "FINALE"
FLAGS = (REAL)
Elt No. 0
SV = PV(0x7fc549002780) at 0x7fc549802ac0
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x7fc548d0ab50 "ok - our destructionn"0
CUR = 21
LEN = 32
ok - our destruction
DESTRUCT
Thursday, May 8, 14
Thursday, May 8, 14
DESTRUCT
• Beware! Our current perlcc compiler does
not do global destruction.
• The new 5.14 compiler can do global
destruction, but this is not stable yet
Thursday, May 8, 14
Takeaway
package FINALE;
{
$ref3 = bless ["ok - package destructionn"];
my $ref2 = bless ["ok - lexical destructionn"];
our $ref4 = bless ["ok - our destructionn"];
local $ref1 = bless ["ok - dynamic destructionn"];
1;
}
DESTROY {
print $_[0][0];
}
Never use global destruction
Thursday, May 8, 14
Takeaway
package FINALE;
{
$ref3 = bless ["ok - package destructionn"];
my $ref2 = bless ["ok - lexical destructionn"];
our $ref4 = bless ["ok - our destructionn"];
local $ref1 = bless ["ok - dynamic destructionn"];
1;
}
DESTROY {
print $_[0][0];
}
Never use global destruction
Never use our objects, always my
Thursday, May 8, 14
Why?
• With old perlcc DESTROY methods of
global or our objects are not called.
Thursday, May 8, 14
Questions?
Thursday, May 8, 14

More Related Content

What's hot

Hudson以外の何か with 任意
Hudson以外の何か with 任意Hudson以外の何か with 任意
Hudson以外の何か with 任意
bleis tift
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
Emmanuel Garcia
 

What's hot (14)

Introduction to Grails
Introduction to Grails Introduction to Grails
Introduction to Grails
 
using Virtualbox NAT and shared folder
using Virtualbox NAT and shared folderusing Virtualbox NAT and shared folder
using Virtualbox NAT and shared folder
 
gemdiff
gemdiffgemdiff
gemdiff
 
it's only abuse if it crashes
it's only abuse if it crashesit's only abuse if it crashes
it's only abuse if it crashes
 
Ceph OSD Op trace
Ceph OSD Op traceCeph OSD Op trace
Ceph OSD Op trace
 
Raspberry Pi for IPRUG
Raspberry Pi for IPRUGRaspberry Pi for IPRUG
Raspberry Pi for IPRUG
 
Hudson以外の何か with 任意
Hudson以外の何か with 任意Hudson以外の何か with 任意
Hudson以外の何か with 任意
 
シェル芸でライフハック(特論)
シェル芸でライフハック(特論)シェル芸でライフハック(特論)
シェル芸でライフハック(特論)
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
Mikhail Belopuhov: OpenBSD: Where is crypto headed?
Mikhail Belopuhov: OpenBSD: Where is crypto headed?Mikhail Belopuhov: OpenBSD: Where is crypto headed?
Mikhail Belopuhov: OpenBSD: Where is crypto headed?
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourDevoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
 
GeeCON Prague 2018 - Kotlin DSL in under an hour
GeeCON Prague 2018 - Kotlin DSL in under an hourGeeCON Prague 2018 - Kotlin DSL in under an hour
GeeCON Prague 2018 - Kotlin DSL in under an hour
 
Vim再入門
Vim再入門Vim再入門
Vim再入門
 
Tutorial to make sure of nginx files starterpack.
Tutorial to make sure of nginx files starterpack.Tutorial to make sure of nginx files starterpack.
Tutorial to make sure of nginx files starterpack.
 

Viewers also liked (7)

Gold - global initiative against COPD
Gold - global initiative against COPDGold - global initiative against COPD
Gold - global initiative against COPD
 
Nebulizer
NebulizerNebulizer
Nebulizer
 
Mechanical Ventilation in ARDS vs COPD
Mechanical Ventilation in ARDS vs COPDMechanical Ventilation in ARDS vs COPD
Mechanical Ventilation in ARDS vs COPD
 
Role of Inhaled Corticosteroids in COPD
Role of Inhaled Corticosteroids  in COPDRole of Inhaled Corticosteroids  in COPD
Role of Inhaled Corticosteroids in COPD
 
ppok
ppokppok
ppok
 
COPD
COPDCOPD
COPD
 
COPD (Chronic obstructive Pulmonary Disease) PowerPoint Presentation -aslam
COPD  (Chronic obstructive Pulmonary Disease) PowerPoint Presentation -aslamCOPD  (Chronic obstructive Pulmonary Disease) PowerPoint Presentation -aslam
COPD (Chronic obstructive Pulmonary Disease) PowerPoint Presentation -aslam
 

Similar to Global destruction (in 5 minutes)

Complementing Docker with Puppet
Complementing Docker with PuppetComplementing Docker with Puppet
Complementing Docker with Puppet
Docker, Inc.
 

Similar to Global destruction (in 5 minutes) (11)

Naughty And Nice Bash Features
Naughty And Nice Bash FeaturesNaughty And Nice Bash Features
Naughty And Nice Bash Features
 
Kernel Recipes 2016 - Why you need a test strategy for your kernel development
Kernel Recipes 2016 - Why you need a test strategy for your kernel developmentKernel Recipes 2016 - Why you need a test strategy for your kernel development
Kernel Recipes 2016 - Why you need a test strategy for your kernel development
 
Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Dockerize everything TopConf Tallinn
Dockerize everything TopConf TallinnDockerize everything TopConf Tallinn
Dockerize everything TopConf Tallinn
 
Complementing Docker with Puppet
Complementing Docker with PuppetComplementing Docker with Puppet
Complementing Docker with Puppet
 
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
The Next Step in AS3 Framework Evolution - FITC Amsterdam 2013
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
 
Current State of Coroutines
Current State of CoroutinesCurrent State of Coroutines
Current State of Coroutines
 
Everything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsEverything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap Dumps
 

Recently uploaded

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 

Recently uploaded (20)

CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 

Global destruction (in 5 minutes)

  • 2. in 5 minutes There’s another talk: Global Destruction in 20 Minutes Thursday, May 8, 14
  • 4. What is global destruction? • Perl has a couple of run-time phases: BEGIN, CHECK, UNITCHECK, INIT, runloop, END, DESTRUCT • perldoc perlmod Thursday, May 8, 14
  • 5. What is global destruction? • BEGIN, CHECK, UNITCHECK, INIT, runloop, END, DESTRUCT • DESTRUCT cannot be called by DESTRUCT {} blocks. Thursday, May 8, 14
  • 6. What is global destruction? • BEGIN, CHECK, UNITCHECK, INIT, runloop, END, DESTRUCT • DESTRUCT cannot be called by DESTRUCT {} blocks. • the runloop neither Thursday, May 8, 14
  • 7. DESTRUCT • DESTRUCT is executed after PerlIO_destruct and before PerlIO_clean • DESTRUCT calls DESTROY methods on all objects which do have a DESTROY method (sv_clean_obj) Thursday, May 8, 14
  • 8. package FINALE; { $ref3 = bless ["ok - package destruction"]; my $ref2 = bless ["ok - lexical destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } DEMO t/testc.sh -A -O3 -k 197 DESTRUCT Thursday, May 8, 14
  • 9. DESTRUCT • Beware! Our current perlcc compiler does not do global destruction. • 2nd warning: our variables behave like globals! Use only my, not our Thursday, May 8, 14
  • 10. package FINALE; { $ref3 = bless ["ok - package destructionn"]; my $ref2 = bless ["ok - lexical destructionn"]; our $ref4 = bless ["ok - our destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } => ok - dynamic destruction ok - lexical destruction ok - package destruction ok - our destruction DESTRUCT Thursday, May 8, 14
  • 11. perl debugging: -DD (-D? => D Cleaning up) $ ./ccode197_o3 -DD EXECUTING... ok - dynamic destruction ok - lexical destruction Cursing named global static sv_arena: Calling FINALE::DESTROY ok - package destruction sv_arena: 0x7ff9b982f600 - 0x7ff9b98305f0 (170) sv_arena: 0x7ff9b982ae00 - 0x7ff9b982bdf0 (170) sv_arena: 0x7ff9b9807800 - 0x7ff9b98087f0 (170) Cleaning named glob IO object: SV = PVIO(0x7ff9b982ce00) at 0x7ff9b982b7a8 REFCNT = 2 FLAGS = (OBJECT) STASH = 0x7ff9b982b268! "IO::File" ... DESTRUCT Thursday, May 8, 14
  • 12. ok - dynamic destruction ok - lexical destruction Cursing named global static sv_arena: Calling FINALE::DESTROY ok - package destruction Cleaning object ref: SV = IV(0x10076dce8) at 0x10076dcf8 REFCNT = 1 FLAGS = (ROK) RV = 0x7fc549802aa8 SV = PVAV(0x7fc549005530) at 0x7fc549802aa8 FLAGS = (OBJECT) STASH = 0x7fc5490287f8! "FINALE" FLAGS = (REAL) Elt No. 0 SV = PV(0x7fc549002780) at 0x7fc549802ac0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x7fc548d0ab50 "ok - our destructionn"0 CUR = 21 LEN = 32 ok - our destruction DESTRUCT Thursday, May 8, 14
  • 14. DESTRUCT • Beware! Our current perlcc compiler does not do global destruction. • The new 5.14 compiler can do global destruction, but this is not stable yet Thursday, May 8, 14
  • 15. Takeaway package FINALE; { $ref3 = bless ["ok - package destructionn"]; my $ref2 = bless ["ok - lexical destructionn"]; our $ref4 = bless ["ok - our destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } Never use global destruction Thursday, May 8, 14
  • 16. Takeaway package FINALE; { $ref3 = bless ["ok - package destructionn"]; my $ref2 = bless ["ok - lexical destructionn"]; our $ref4 = bless ["ok - our destructionn"]; local $ref1 = bless ["ok - dynamic destructionn"]; 1; } DESTROY { print $_[0][0]; } Never use global destruction Never use our objects, always my Thursday, May 8, 14
  • 17. Why? • With old perlcc DESTROY methods of global or our objects are not called. Thursday, May 8, 14