proxy-super is not threadsafe

110 views
Skip to first unread message

Kevin Downey

unread,
Jun 26, 2017, 2:35:01 PM6/26/17
to cloju...@googlegroups.com
I happened to be looking at the proxy-super macro last week and noticed
that it isn't threadsafe (technically any call to a method that then
uses proxy-super makes it unsafe to call that method until proxy-super
returns, same thread or otherwise).

It seems like the doc string for proxy-super should at least mention
that it is not safe, and better yet if it could somehow be made safe.

https://gist.github.com/hiredman/a42f83c2708bf6291a75c9372ad26525 is
some example code that can be pasted in to the repl showing unsafe behavior.

I haven't filed a jira issue because I don't know if this is something
that I am alone in thinking should be addressed, and which route to go
when addressing it (doc string vs. behavior change).

--
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

Alex Miller

unread,
Jun 26, 2017, 4:38:49 PM6/26/17
to cloju...@googlegroups.com
Ok by me to file it. I'm not sure if it's possible to fix it completely due to the nature of proxies? I wonder if you could use threadlocals to narrow the scope substantially (or maybe that could be a new function).



--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev+unsubscribe@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.

Christophe Grand

unread,
Jun 30, 2017, 4:10:48 AM6/30/17
to clojure-dev
A couple of weks ago, I was looking at proxy-super too and wondered if having generate-proxy to emit for each foo method a super$foo method (whose body would just be the invokespecial to perform the call to the super implementention of foo)  could be an acceptable solution:
* no more map switching issues,
* (proxy-super foo x y z) would expand to (.super$foo this x y z)
--
On Clojure http://clj-me.cgrand.net/
Clojure Programming http://clojurebook.com
Training, Consulting & Contracting http://lambdanext.eu/
Reply all
Reply to author
Forward
0 new messages