This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libobjc/38307] Calling of the +initialize method is not completely thread-safe
- From: "rfm at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Mar 2011 12:43:53 +0000
- Subject: [Bug libobjc/38307] Calling of the +initialize method is not completely thread-safe
- Auto-submitted: auto-generated
- References: <bug-38307-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38307
--- Comment #4 from rfm at gnu dot org 2011-03-16 12:43:39 UTC ---
I just searched this old bug report up, and found that I'd missed seeing (or
forgotten about) the latest response :-(
I've been running with my patch for a couple of years without problems, but
when I tried David's patch out, practically all my gnustep code simply started
crashing on startup ... so there's something wrong there but I haven't had time
to see what it might be.
However, to address points in the last comment ...
> I still have a hard time groking what was intended with the receiver. It all
> seems very intertwined and I think there is a more straight forward way to
> implement this.
I can't argue with that ... it *is* complex :-(
> Also, with this patch get_imp fails on class methods. (get_imp also has the
> nasty effect of installing the dispatch table without calling +initialize and
> the same goes for __objc_responds_to).
Very good point ... it hasn't been an issue for me in practice, but that
clearly is something which needs to be addressed. However, I'm not sure that's
a new bug ... haven't those functions always bypassed +initialize? I'd have to
check, but I agree that they really should call +initialize
> I'm not to fond of introducing InitializingList as special type. I think should
> be fine with using the existing hash map tables for this. I don't think we
> really need to introduce a new type. Do you really think that method dispatch
> for partially installed dispatch tables is performance critical?
Certainly there's no performance issue with method dispatch in initialize ...
it should be rare enough that we can use a really slow implementation.
However, we have to build the dispatch table for the class, so it seemed
reasonable to use it within the thread calling +initialize even though we don't
want to install it for other threads until +initialize has completed. Perhaps
we can store the uninstalled dispatch tables in a hash map more simply than
using a new type ... that sounds reasonable.