[
https://issues.apache.org/jira/browse/CLOWNFISH-78?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15189400#comment-15189400
]
Nick Wellnhofer commented on CLOWNFISH-78:
------------------------------------------
Delaying the initialization of the global class pointer has a couple of other
consequences that make a lock-free solution difficult:
- If the parent class is from the same parcel, its properties must not be
looked up through the global class pointer, but through the ClassSpec array.
- When bootstrapping the Clownfish parcel, Strings and Methods can't be created
safely because another thread might have succeeded in creating the String or
Method class earlier. We should probably store the ClassSpec pointer in Class
and use it to create String and Method objects lazily.
- When bootstrapping the Clownfish parcel, we can't call
{{Class_Init_Obj_IMP(CLASS, klass)}} because CLASS is not initialized yet.
Especially the last point is problematic because the following operations must
be executed atomically:
- Initialize OBJ.
- Initialize CLASS.
- Set OBJ->klass to CLASS.
- Set CLASS->parent to OBJ.
On the plus side, it should be possible to simplify the rest of the
bootstrapping process because, if we solve these problems, we don't need
separate passes anymore.
> Bootstrap process isn't thread-safe
> -----------------------------------
>
> Key: CLOWNFISH-78
> URL: https://issues.apache.org/jira/browse/CLOWNFISH-78
> Project: Apache Lucy-Clownfish
> Issue Type: Bug
> Reporter: Nick Wellnhofer
>
> The Clownfish bootstrap process isn't thread-safe. For a lock-free solution:
> - Class_bootstrap must set the global class pointer at the very end, possibly
> destroying the class if another thread set the pointer before.
> - The runtime inheritance cycle detection must be reworked, or simply left
> out. It only protects from a really contrived scenario.
> - Probably other things I missed.
> We could also consider a global lock using a locking facility provided by the
> host language.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)