Author: Ronan Lamy <[email protected]>
Branch: exctrans
Changeset: r81859:7ec528e70b0f
Date: 2016-01-19 18:52 +0000
http://bitbucket.org/pypy/pypy/changeset/7ec528e70b0f/
Log: Backed out changeset 2906290a8ebc
The issue is that creating the external function stubs prevents the
functions that need to be sandbox-transformed from being annotated
correctly.
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -358,10 +358,6 @@
return self.descs[obj_key]
except KeyError:
if isinstance(pyobj, types.FunctionType):
- if self.annotator.translator.config.translation.sandbox:
- if hasattr(pyobj, '_ptr') and not getattr(pyobj._ptr._obj,
'_safe_not_sandboxed', True):
- from rpython.translator.sandbox.rsandbox import
get_sandbox_stub
- pyobj = get_sandbox_stub(pyobj._ptr._obj)
result = description.FunctionDesc(self, pyobj)
elif isinstance(pyobj, (type, types.ClassType)):
if pyobj is object:
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -903,12 +903,26 @@
funcgen.implementation_end()
def new_funcnode(db, T, obj, forcename=None):
+ sandbox = db.sandbox and need_sandboxing(obj)
+ if sandbox:
+ if getattr(obj, 'external', None) is not None:
+ obj.__dict__['graph'] = rsandbox.get_sandbox_stub(
+ obj, db.translator.rtyper)
+ obj.__dict__.pop('_safe_not_sandboxed', None)
+ obj.__dict__.pop('external', None)
+
if forcename:
name = forcename
else:
name = _select_name(db, obj)
return FuncNode(db, T, obj, name)
+def need_sandboxing(fnobj):
+ if hasattr(fnobj, '_safe_not_sandboxed'):
+ return not fnobj._safe_not_sandboxed
+ else:
+ return "if_external"
+
def select_function_code_generators(fnobj, db, functionname):
if hasattr(fnobj, 'graph'):
exception_policy = getattr(fnobj, 'exception_policy', None)
diff --git a/rpython/translator/sandbox/rsandbox.py
b/rpython/translator/sandbox/rsandbox.py
--- a/rpython/translator/sandbox/rsandbox.py
+++ b/rpython/translator/sandbox/rsandbox.py
@@ -117,11 +117,13 @@
dump_string = rmarshal.get_marshaller(str)
load_int = rmarshal.get_loader(int)
-def get_sandbox_stub(fnobj):
- """Build always-raising stub function for unsupported external function."""
+def get_sandbox_stub(fnobj, rtyper):
+ """Build always-raising graph for unsupported external function."""
fnname = fnobj._name
+ args_s, s_result = sig_ll(fnobj)
msg = "Not implemented: sandboxing for external function '%s'" % (fnname,)
- return make_stub(fnname, msg)
+ execute = make_stub(fnname, msg)
+ return _annotate(rtyper, execute, args_s, s_result)
def get_external_function_sandbox_graph(fnobj, rtyper):
"""Build the graph of a helper trampoline function to be used
diff --git a/rpython/translator/sandbox/test/test_sandbox.py
b/rpython/translator/sandbox/test/test_sandbox.py
--- a/rpython/translator/sandbox/test/test_sandbox.py
+++ b/rpython/translator/sandbox/test/test_sandbox.py
@@ -8,7 +8,6 @@
from rpython.translator.interactive import Translation
from rpython.translator.sandbox.sandlib import read_message, write_message
from rpython.translator.sandbox.sandlib import write_exception
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
if hasattr(signal, 'alarm'):
_orig_read_message = read_message
@@ -293,16 +292,6 @@
rescode = pipe.wait()
assert rescode == 0
-def test_llexternal():
- c_foo = rffi.llexternal('foo', [], rffi.INT)
- def f(argv):
- try:
- c_foo()
- except:
- pass
- return 0
- compile(f) # Check that this doesn't crash
-
class TestPrintedResults:
def run(self, entry_point, args, expected):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit