public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: Per Bothner <per@bothner.com>, kawa <kawa@sourceware.org>
Subject: Re: Evaluating definitions from another thread
Date: Sun, 12 May 2024 23:08:55 +0200	[thread overview]
Message-ID: <CAMFYt2YQ6zba0GYjJ=Pfx70_jq71PyDhZiX6b6iC-HFErJBm=w@mail.gmail.com> (raw)
In-Reply-To: <4c435a3e-0517-46c5-b541-88f1355dfe4b@bothner.com>

[-- Attachment #1: Type: text/plain, Size: 2675 bytes --]

sob., 11 maj 2024 o 17:44 Per Bothner <per@bothner.com> napisał(a):

> If you allow the user to evaluate arbitrary expressions, that should be
> done in a separate
> context (environment) than GRASP itself. The user context should not
> inherit everything from
> the GRASP context; only deliberately exported bindings, mostly read-only.
> And the user context
> should not be able to add or modify arbitrary bindings in the GRASP
> context; only bindings
> that the GRASP engine deliberately amkes available to the eval context.
>

I agree that, at some point, this will need to be addressed - in
particular, when people start sharing
extensions that they write, I'll need to create a model for managing access
to particular parts
of the system.

However, at this moment coming up with a compelling way of creating
extensions is much more
important.



> This is security 101. Of course if you just want to make some someware for
> yourself to
> learn or play around with, do what you like. But if you want to write
> software for others
> to use, you need to consider security issues.
>
> If you want each evaluation to be performed on a separate thread, then you
> need to consider
> how things are synchronized: How updates in the eval thread cause changes
> in the GRASP engine.
> It is possible that using parameters will "do the right thing" - but I
> wouldn't count on it.
>
>
Today I developed the following subclass of ThreadLocation:

https://github.com/panicz/grasp/compare/main...shared-parameters

The idea is that the values stored in the thread locations are themselves
SharedLocations.
According to my test, they behave as expected:

(define x (make-shared-parameter 'x 0))

(parameterize ((x 1))
  (future
   (begin
     (sleep 1)
     (display "changing x from ")
     (display (x))
     (set! (x) 2)
     (display " to ")
     (display (x))
     (newline)))
  (display "inner value of x: ")
  (display (x))
  (newline)
  (sleep 2)
  (display "inner value of x after 2 seconds: ")
  (display (x))
  (newline)
  )

(display "outer value of x: ")
(display (x))
(newline)

 The output produced by running the above program is

inner value of x: 1
changing x from 1 to 2
inner value of x after 2 seconds: 2
outer value of x: 0


whereas if - instead of using "shared parameters", I use the regular
parameters, I get

inner value of x: 1
changing x from 1 to 2
inner value of x after 2 seconds: 1
outer value of x: 0

I didn't quite understand why the constructor of SharedLocation requires a
timestamp, and I passed it (java.lang.System:currentTimeMillis).
Is that OK?

  parent reply	other threads:[~2024-05-12 21:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 20:15 Panicz Maciej Godek
2024-05-10 20:19 ` Per Bothner
2024-05-10 21:03   ` Panicz Maciej Godek
2024-05-11  0:49     ` Per Bothner
     [not found]       ` <CAMFYt2bqd3LNLPFgdhpaDrSkdM_SLGCGYnSqs0-gw0Z9n-OFqw@mail.gmail.com>
     [not found]         ` <4c435a3e-0517-46c5-b541-88f1355dfe4b@bothner.com>
2024-05-12 21:08           ` Panicz Maciej Godek [this message]
2024-05-12 21:22             ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMFYt2YQ6zba0GYjJ=Pfx70_jq71PyDhZiX6b6iC-HFErJBm=w@mail.gmail.com' \
    --to=godek.maciek@gmail.com \
    --cc=kawa@sourceware.org \
    --cc=per@bothner.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).