Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero-width substitution makes the GC recurse #1080

Closed
p6rt opened this issue Jun 21, 2009 · 6 comments
Closed

Zero-width substitution makes the GC recurse #1080

p6rt opened this issue Jun 21, 2009 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Jun 21, 2009

Migrated from rt.perl.org#66816 (status was 'resolved')

Searchable as RT66816$

@p6rt
Copy link
Author

p6rt commented Jun 21, 2009

From @moritz

This innocently looking script on Rakudo #​18 sends the GC into an infinite
recursion and thus provokes a segmentation fault​:

use v6;
my $str = "a\nbc\nd";
say $str.subst(/^^/, '# ', :g);

The backtrace looks like this​:
(gdb) bt
#​0 0x00007f95a5c86e55 in mark_special (interp=0x176e010, obj=0x25a8180)
  at src/gc/mark_sweep.c​:460
#​1 0x00007f95a5c84633 in Parrot_gc_mark_PObj_alive (interp=0x176e010,
  obj=0x25a8180) at src/gc/api.c​:162
#​2 0x00007f95a5cf725b in mark_context (interp=0x176e010, ctx=0x1fd0250)
  at src/sub.c​:91
#​3 0x00007f95a5dbdb8f in Parrot_Sub_mark (interp=0x176e010, pmc=0x25a81b0)
  at ./src/pmc/sub.pmc​:505
#​4 0x00007f95a5dc0b82 in Parrot_Coroutine_mark (interp=0x176e010,
  pmc=0x25a81b0) at ./src/pmc/coroutine.pmc​:264
#​5 0x00007f95a5c86e57 in mark_special (interp=0x176e010, obj=0x25a81b0)
  at src/gc/mark_sweep.c​:460

and so on, repeating the first five lines all over again.

Cheers,
Moritz

--
Moritz Lenz
http://perlgeek.de/ | http://perl-6.de/ | http://sudokugarden.de/

@p6rt
Copy link
Author

p6rt commented Jun 22, 2009

From @Whiteknight

On Sun Jun 21 10​:44​:09 2009, mlenz@​physik.uni-wuerzburg.de wrote​:

This innocently looking script on Rakudo #​18 sends the GC into an infinite
recursion and thus provokes a segmentation fault​:

use v6;
my $str = "a\nbc\nd";
say $str.subst(/^^/, '# ', :g);

The backtrace looks like this​:
(gdb) bt
#​0 0x00007f95a5c86e55 in mark_special (interp=0x176e010, obj=0x25a8180)
at src/gc/mark_sweep.c​:460
#​1 0x00007f95a5c84633 in Parrot_gc_mark_PObj_alive (interp=0x176e010,
obj=0x25a8180) at src/gc/api.c​:162
#​2 0x00007f95a5cf725b in mark_context (interp=0x176e010, ctx=0x1fd0250)
at src/sub.c​:91
#​3 0x00007f95a5dbdb8f in Parrot_Sub_mark (interp=0x176e010,
pmc=0x25a81b0)
at ./src/pmc/sub.pmc​:505
#​4 0x00007f95a5dc0b82 in Parrot_Coroutine_mark (interp=0x176e010,
pmc=0x25a81b0) at ./src/pmc/coroutine.pmc​:264
#​5 0x00007f95a5c86e57 in mark_special (interp=0x176e010, obj=0x25a81b0)
at src/gc/mark_sweep.c​:460

and so on, repeating the first five lines all over again.

Cheers,
Moritz

I've seen bugs like this in other places before. What happened in those
other examples was an infinite subroutine recursion, which eventually
triggered the GC to cleanup all the mess (Sub PMC -> context -> Sub ->
context -> Sub, etc). Could you go up to the top of the stack trace and
take a look for a pattern like that?

--
Andrew Whitworth
a.k.a Whiteknight

@p6rt
Copy link
Author

p6rt commented Jun 22, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jun 25, 2010

From @bbkr

tests added to t/spec/S05-substitution/subst.t
Committed revision 31445.

@p6rt
Copy link
Author

p6rt commented Jun 25, 2010

@bbkr - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jun 25, 2010
@p6rt
Copy link
Author

p6rt commented Jun 25, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S05-substitution/subst.t

commit 14f573cb19cc83439e8b70117484b058fd03e2a3
Author​: bbkr <bbkr@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Fri Jun 25 14​:47​:38 2010 +0000

  [t/spec/S05-substitution/subst.t] tests for RT #​66816 Zero-width substitution makes the GC recurse
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31445 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S05-substitution/subst.t b/t/spec/S05-substitution/subst.t
index 6f4d1e1..46ab4d6 100644
--- a/t/spec/S05-substitution/subst.t
+++ b/t/spec/S05-substitution/subst.t
@@ -304,6 +304,13 @@ is '12'.subst(/(.)(.)/,{$()*2}),'24', '.. and do nifty things in closures';
     is 'The foo and the bar'.subst(/:i the/, {$str++}, :g, :samecase), 'Thau foo and thav bar', '.substr and :g and :samecase, worked with block replacement';
 }
 
+# RT #66816
+{
+    my $str = "a\nbc\nd";
+    is $str.subst(/^^/, '# ', :g), "# a\n# bc\n# d",
+        'Zero-width substitution does not make the GC recurse';
+}
+
 done_testing;
 
 # vim: ft=perl6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant