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

Bufs in Safe #109

Closed
p5pRT opened this issue Jun 24, 1999 · 1 comment
Closed

Bufs in Safe #109

p5pRT opened this issue Jun 24, 1999 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Jun 24, 1999

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

Searchable as RT913$

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 1999

From tchrist@jhereg.perl.com

  use Safe;
  $| = 1;

  my $DO_STRICT = 1;

  my $box = new Safe("Eval");
  $box->permit_only(qw{​:base_core});

  @​codes = (
  q{ $var->{'z'} = 12 },
  q{ defined $var->{'z'} },
  q{ $var = {} },
  q{ $var->{'y'} =~ /letter/ },
  q{ $var->{'z'} + 3 },
  q{ unlink $fred },
  q{ $var->{a}{b}{c} },
  q{ while (1) { } },
  q{ last },
  q{ return },
  q{ do 'grinch' },
  q{ require Help },
  );

  for $code (@​codes) {
  $i++;
  print "Running code #$i​: $code\n\t";
  $@​ = '';
  my $rv = $box->reval($code, $DO_STRICT);
  if (!defined $rv && $@​) {
  print("SAFE TRAP​: $@​\n");
  } else {
  if (defined $rv) {
  print qq(Retval = "$rv"\n\n);
  } else {
  print "Retval is <UNDEF>\n\n";
  }
  }
  }

Produces this output. Some of it is suspect.

  Running code #1​: $var->{'z'} = 12
  Global symbol "$var" requires explicit package name at (eval 2) line 1.
  Retval is <UNDEF>

  Running code #2​: defined $var->{'z'}
  Retval = ""

  Running code #3​: $var = {}
  SAFE TRAP​: anonymous hash trapped by operation mask at (eval 6) line 1.

  Running code #4​: $var->{'y'} =~ /letter/
  Retval = ""

  Running code #5​: $var->{'z'} + 3
  Retval = "3"

  Running code #6​: unlink $fred
  Global symbol "$fred" requires explicit package name at (eval 12) line 2.
  SAFE TRAP​: unlink trapped by operation mask at (eval 12) line 2.

  Running code #7​: $var->{a}{b}{c}
  Retval is <UNDEF>

  Running code #8​: while (1) { }
  SAFE TRAP​: loop exit trapped by operation mask at (eval 16) line 2.

  Running code #9​: last
  SAFE TRAP​: last trapped by operation mask at (eval 18) line 2.

  Running code #10​: return
  Retval is <UNDEF>

  Running code #11​: do 'grinch'
  SAFE TRAP​: do 'file' trapped by operation mask at (eval 22) line 2.

  Running code #12​: require Help
  SAFE TRAP​: require trapped by operation mask at (eval 24) line 3.

Issues​:

  Test code 1​: Why did the strict stuff leak out stderr, dang it!?
  Why did it not kill the compile?

  Test code 2​: Why did this autovivify and not trigger the
  same fault as test 3 did?
  Why is it not triggering the same complaint as
  test code 1 did?

  Test code 6​: More evil strict leakage out stderr.

  Text code 8​: I wrote it this way to show that it was not permissible,
  even though 1 while 1 is!

What do you think? This strict leakage is a real super pain.

--tom

--
  I'm sure that that could be indented more readably, but I'm scared of
  the awk parser. --Larry Wall in <6849@​jpl-devvax.JPL.NASA.GOV>

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