racket icon indicating copy to clipboard operation
racket copied to clipboard

Sandbox forbids access to transformer of macro in binding space

Open michaelballantyne opened this issue 3 years ago • 0 comments

What version of Racket are you using?

8.4.0.8 [cs]

What program did you run?

sp-a.rkt:

#lang racket

(provide
 (for-space sp x)
 m)

(define-syntax (define-syntax/sp stx)
  (syntax-case stx ()
    [(_ var rhs)
     (with-syntax ([sp-var ((make-interned-syntax-introducer 'sp) #'var)])
       #'(define-syntax sp-var rhs))]))

(define-syntax/sp x 'x-info)

(define-syntax (m stx)
  (syntax-case stx ()
    [(_ id)
     #`'#,(syntax-local-value ((make-interned-syntax-introducer 'sp) #'id))]))

sp-b.rkt

#lang racket

(require racket/sandbox)

(define evaluator
  (make-evaluator 'racket/base
                  '(require "sp-a.rkt")
                  #:allow-for-require (list "sp-a.rkt")))

(evaluator '(m x))

What should have happened?

The expression (evaluator '(m x)) should evaluate to 'x-info.

If you got an error message, please include it here.

eval:1:0: ?: access disallowed by code inspector to unexported transformer
  from module: "/Users/michaelballantyne/Desktop/sp-a.rkt" in: x

The analogous code that does not use binding spaces works:

a.rkt:

#lang racket

(provide
 x
 m)

(define-syntax x 'x-info)

(define-syntax (m stx)
  (syntax-case stx ()
    [(_ id)
     #`'#,(syntax-local-value #'id)]))

b.rkt:

#lang racket

(require racket/sandbox)

(define evaluator
  (make-evaluator 'racket/base
                  '(require "a.rkt")
                  #:allow-for-require (list "a.rkt")))

(evaluator '(m x))

michaelballantyne avatar Mar 18 '22 20:03 michaelballantyne