Make sure that the module is also instantiated under the evaluation

limits too (the instantiation was happening outside of the limited
thunk)

svn: r12830
This commit is contained in:
Eli Barzilay 2008-12-13 16:41:07 +00:00
parent f878d96630
commit 55f1df58e1
2 changed files with 21 additions and 7 deletions

View File

@ -443,18 +443,20 @@
(define (evaluate-program program limit-thunk uncovered!)
(when uncovered!
(eval `(,#'#%require scheme/private/sandbox-coverage)))
;; the actual evaluation happens under the specified limits
((limit-thunk (lambda ()
(if (and (pair? program) (eq? 'begin (car program)))
(eval* (cdr program))
(eval program)))))
(let ([ns (syntax-case* program (module) literal-identifier=?
[(module mod . body)
(identifier? #'mod)
(let ([mod #'mod])
(eval `(,#'require (quote ,mod)))
(module->namespace `(quote ,(syntax-e mod))))]
(lambda ()
(eval `(,#'require (quote ,mod)))
(module->namespace `(quote ,(syntax-e mod)))))]
[_else #f])])
;; the actual evaluation happens under the specified limits
((limit-thunk (lambda ()
(if (and (pair? program) (eq? 'begin (car program)))
(eval* (cdr program))
(eval program))
(when ns (set! ns (ns))))))
(when uncovered!
(let ([get (let ([ns (current-namespace)])
(lambda () (eval '(get-uncovered-expressions) ns)))])

View File

@ -137,6 +137,18 @@
x =err> "terminated"
,eof =err> "terminated"
;; eval-limits apply to the sandbox creation too
--top--
(set! ev (parameterize ([sandbox-eval-limits '(0.25 5)])
(make-evaluator 'scheme/base '(sleep 2))))
=err> "out of time"
(set! ev (parameterize ([sandbox-eval-limits '(0.25 2)])
(make-evaluator 'scheme/base
'(define a (for/list ([i (in-range 10)])
(collect-garbage)
(make-string 1000))))))
=err> "out of memory"
;; i/o
--top--
(set! ev (parameterize ([sandbox-input "3\n"]