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

stack overflow with moderately complex data structures [rt.cpan.org #97525] #19

Open
atoomic opened this issue Oct 25, 2018 · 1 comment

Comments

@atoomic
Copy link
Collaborator

atoomic commented Oct 25, 2018

Migrated from rt.cpan.org#97525 (status was 'open')

Requestors:

From [email protected] on 2014-07-26 13:33:50:

This comes from the discussion of [rt.cpan.org #97508]:

$ ulimit -s
8192
$ perl -e 'use Clone qw(clone); $t = [$t] for 1..30000; clone $t'
$ perl -e 'use Clone qw(clone); $t = [$t] for 1..40000; clone $t'
Segmentation fault (core dumped)
$ ulimit -s 16348
$ perl -e 'use Clone qw(clone); $t = [$t] for 1..40000; clone $t'
$ perl -e 'use Clone qw(clone); $t = [$t] for 1..60000; clone $t'
$ perl -e 'use Clone qw(clone); $t = [$t] for 1..70000; clone $t'
Segmentation fault (core dumped)
$ dpkg -l perl libclone-perl | grep ii
ii  libclone-perl  0.36-1           amd64  module for recursively copying Perl datatypes
ii  perl           5.18.2-2ubuntu1  amd64  Larry Wall's Practical Extraction and Report Language

The same happens with:
$ perl -e 'use threads; $t = [$t] for 1..30000; (async {})->join'
Segmentation fault (core dumped)
$ perl -e 'use Storable qw(dclone); $t = [$t] for 1..30000; dclone $t'
Segmentation fault (core dumped)

From [email protected] on 2015-11-06 14:42:26:

According to this stack trace (generated by stsc) this is a recursion only involving av_clone() and sv_clone() from auto/Clone/Clone.so , which is completely internal to the Clone distribution:

http://perlpunks.de/paste/show/563ba05b.425c.da?plain=1

I would humbly suggest switching from recursion to some explicitly coded iterative traversal (e.g. maintaining an explicit recursion stack in the heap).

Ralf
@atoomic
Copy link
Collaborator Author

atoomic commented Oct 25, 2018

with perl 5.28.0

> perl -e 'use Storable qw(dclone); $t = [$t] for 1..30000; dclone $t'
Max. recursion depth with nested structures exceeded at -e line 1.

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

No branches or pull requests

1 participant