[racket] instantiating multiple sandboxes with gui's

From: Greg Hendershott (greghendershott at gmail.com)
Date: Thu Apr 3 17:26:15 EDT 2014

So the background for Spencer's question was a problem with my Emacs
racket-mode when using racket/gui/base.

There's a long-ish bug report comment thread. If you want to read it,
at all, you might want to skip to the last few comments, here:

  https://github.com/greghendershott/racket-mode/issues/26#issuecomment-39494285

Or the TL;DR: I probably don't need racket/sandbox at all. I probably
just need a new namespace and a custodian -- in order to do a
DrRacket-style "reset the REPL to the source file".

Matthew and Robby I know you're both incredibly busy, but if either of
you had a chance to look at this code, I'd be grateful. Although part
of me hopes you'll say "perfect!", the older/wiser part of me hopes
you'll point out X Y and Z problems I don't yet realize I have. It's
just these 30 lines of code here:

  https://github.com/greghendershott/racket-mode/blob/experimental/sandbox.rkt#L30-L66

On Sun, Mar 23, 2014 at 8:35 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> It is safe, however, to share the racket/gui/base that you get with the one
> in the sandbox.
>
> Robby
>
>
> On Sun, Mar 23, 2014 at 7:25 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>>
>> Yes, this is a limitation of `racket/gui/base`. On initialization, the
>> library must register in various non-composable ways with an underlying
>> GUI toolkit (callbacks, Objective-C classes, Win32 classes, etc.), and
>> so `racket/gui/base` cannot be instantiated multiple times.
>>
>> At Sun, 23 Mar 2014 20:12:43 -0400, Spencer Florence wrote:
>> > I'm attempting to launch multiple evaluators which require `racket/gui`,
>> > however I get the error:
>> >
>> > cannot instantiate `racket/gui/base` a second time in the same process
>> >
>> > Is `racket/gui/base` maintaining some kind of state thats escaping the
>> > sandbox?
>> >
>> >
>> >
>> >
>> >
>> > Example of the problem:
>> >
>> > #lang racket/base
>> > (require racket/sandbox)
>> >
>> > (call-with-trusted-sandbox-configuration
>> >  (lambda ()
>> >    (define (make)
>> >      (make-evaluator 'racket/base
>> >                      #:requires '(racket/gui/base)))
>> >
>> >    (make)
>> >    (make)))
>> > ____________________
>> >   Racket Users list:
>> >   http://lists.racket-lang.org/users
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

Posted on the users mailing list.