RVM

Race in setting finalizer method

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Not A Bug
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Runtime
  • Labels:
    None
  • Number of attachments :
    0

Description

We set the finalizer method of a class after the class is resolved. Resolving a class is not unpreemptible or uninterruptible and neither is the call to findVirtualMethod, therefore there is a race:

1) we publish a class as resolved
2) we call findVirtualMethod hitting the prologue yield point and scheduling a different thread
3) we create an object of the class and don't register the object with the finalizer thread (as hasFinalizer will return false)
4) the object gets garbage collected and the finalizer isn't run

I believe we shouldn't be publish a class as resolved until we have set its finalizeMethod, this will require an internal findVirtualMethod that doesn't check isResolved.

Issue Links

Activity

Hide
David Grove added a comment -

we won't create an instance of an object until it's state is initialized.

Show
David Grove added a comment - we won't create an instance of an object until it's state is initialized.
Hide
Ian Rogers added a comment -

You're right, I was being misled by the comments.

Show
Ian Rogers added a comment - You're right, I was being misled by the comments.
Hide
David Grove added a comment -

reopening to move fix target to unknown so it won't show in the 3.0.1 release notes.

Show
David Grove added a comment - reopening to move fix target to unknown so it won't show in the 3.0.1 release notes.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: