Skip to content

Commit

Permalink
Merge pull request #119 from aviatesk/avi/globalref
Browse files Browse the repository at this point in the history
escape `GlobalRef`
  • Loading branch information
pfitzseb authored Apr 10, 2024
2 parents 2460d74 + ebbc752 commit 13f09b4
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Infiltrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ function maybe_quote(@nospecialize x)
is_ir_construct(x) && return QuoteNode(x)
isa(x, Expr) && return QuoteNode(x)
isa(x, Symbol) && return QuoteNode(x)
isa(x, GlobalRef) && return QuoteNode(x)
return x
end

Expand Down
22 changes: 22 additions & 0 deletions test/outputs/Julia_globalref_1.1.multiout
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBB
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil> gr
|:(Main.undefvar)
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBBCC
|CCCCCCCCCCCCCCCC
|
|BBBBBBB
22 changes: 22 additions & 0 deletions test/outputs/Julia_globalref_1.10.multiout
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBB
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil> gr
|:(Main.undefvar)
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBBCC
|CCCCCCCCCCCCCCCC
|
|BBBBBBB
22 changes: 22 additions & 0 deletions test/outputs/Julia_globalref_1.6.multiout
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBB
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil> gr
|:(Main.undefvar)
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBBCC
|CCCCCCCCCCCCCCCC
|
|BBBBBBB
22 changes: 22 additions & 0 deletions test/outputs/Julia_globalref_1.7.multiout
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBB
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil> gr
|:(Main.undefvar)
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBBCC
|CCCCCCCCCCCCCCCC
|
|BBBBBBB
22 changes: 22 additions & 0 deletions test/outputs/Julia_globalref_1.8.multiout
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBB
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil> gr
|:(Main.undefvar)
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBBCC
|CCCCCCCCCCCCCCCC
|
|BBBBBBB
22 changes: 22 additions & 0 deletions test/outputs/Julia_globalref_1.9.multiout
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBB
++++++++++++++++++++++++++++++++++++++++++++++++++
|Infiltrating <unknown>
|
|infil> gr
|:(Main.undefvar)
|
|infil>
--------------------------------------------------
|AAAAAAAAAAAAAAAAAAAAAA
|
|BBBBBBBCC
|CCCCCCCCCCCCCCCC
|
|BBBBBBB
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ function infiltry(x)
@infiltry x//x
end

function globalref(m, s)
gr = GlobalRef(m, s)
@infiltrate
return gr
end

@testset "infiltration tests" begin
if Sys.isunix() && VERSION >= v"1.1.0"
using TerminalRegressionTests
Expand Down Expand Up @@ -187,6 +193,10 @@ end
["x\n", "randstring\n", "@exit\n"],
"Julia_imported_globals_$(VERSION.major).$(VERSION.minor).multiout")

run_terminal_test((t) -> globalref(Main, :undefvar), GlobalRef(Main, :undefvar),
["gr\n", "@exit\n"],
"Julia_globalref_$(VERSION.major).$(VERSION.minor).multiout")

# safehouse should not shadow local variables
run_terminal_test((t) -> multiexfiltrate(), nothing,
["i\n", "@continue\n", "i\n", "@exfiltrate\n", "@continue\n", "i\n", "safehouse.i\n", "@continue\n", "@exit\n"],
Expand Down

0 comments on commit 13f09b4

Please sign in to comment.