develooper Front page | perl.perl5.porters | Postings from October 2003

[perl #24347] segfault with Safe

Thread Previous | Thread Next
Ilya Zakharevich
October 28, 2003 20:44
[perl #24347] segfault with Safe
Message ID:
# New Ticket Created by  Ilya Zakharevich 
# Please include the string:  [perl #24347]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from me,
generated with the help of perlbug 1.26 running under perl 5.008001.

The following file still segfaults (5.6.1 as well as 5.8.1).  It works
fine with 5.005_53.  [Of course, it would be simpler if the
functionality was present in the Safe API, instead of trying to
implement it yourselves...]


#!/usr/bin/perl -xw
use strict;
use Safe;

my $main = \%main:: ;

# This is not needed if LWP::Simple is preloaded, or if `caller' is added to
# the `permit' list
my $caller = sub (;$) {@_ ? caller $_[0] + 1: caller 2};

sub call_with_main (&@) {
  my $code = shift;
  my @args = @_;
  # Opcode::_safe_call_sv($obj->{Root}, $obj->{Mask}, $evalsub)
  # Resets the root stash and %INC
  no strict 'refs';
  local *{'__fakemain__::'} = $main;
  Opcode::_safe_call_sv( '__fakemain__', # Let the bugger hide main, then unhide it again...
                         sub {   local *CORE::GLOBAL::caller = $caller;
				 $code->(@args) } );

my $url = "";
sub wget { my $res = call_with_main {	require LWP::Simple;
					LWP::Simple::get(shift) } $url;
	   print $@ if $@;

my $safe = new Safe;


# These two guys use too many opcodes to be loaded inside a compartment
require "$" for qw(IO/Handle IO/Socket);

# Any one of these two is sufficient
#use LWP::Simple;
$safe->permit( qw(require entereval) );

$safe->reval('print wget()');
print $@ if $@;


This perlbug was built using Perl 5.00553 - Thu Nov  5 01:10:17 EST 1998
It is being executed now by  Perl 5.008001 - Thu Sep 25 13:52:17 PDT 2003.

Site configuration information for perl 5.008001:

Configured by vera at Thu Sep 25 13:52:17 PDT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 1 patch 21379) configuration:
    osname=os2, osvers=2.30, archname=os2
    uname='os2 ia-ia 2 2.30 i386 '
    config_args='-des -D prefix=i:/perllib'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
    cc='gcc', ccflags ='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I. -D_EMX_CRT_REV_=64 -I/usr/local/include',
    optimize='-O2 -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 -malign-functions=2 -s',
    cppflags='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I. -D_EMX_CRT_REV_=64 -I/usr/local/include'
    ccversion='', gccversion='2.8.1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-Zexe -Zomf -Zmt -Zcrtdll -Zstack 32000 -Zlinker /e:2'
    libpth=i:/emx.add/lib i:/emx/lib i:/emx.f77/lib D:/DEVTOOLS/OPENGL/LIB I:/JAVA11/LIB i:/emx/lib/mt
    libs=-lsocket -lm -lbsd -lcrypt
    perllibs=-lsocket -lm -lbsd -lcrypt
    libc=i:/emx/lib/mt/c_import.lib, so=dll, useshrplib=true, libperl=libperl.lib
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-Zdll', lddlflags='-Zdll -Zomf -Zmt -Zcrtdll -Zlinker /e:2'

Locally applied patches:

@INC for perl 5.008001:

Environment for perl 5.008001:
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL (unset)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About