Skip to content

Global eventually ignores assignment #1375

@JasonLunn

Description

@JasonLunn

OS X 10.7.5
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18 +indy [darwin-x86_64]
[via rvm 1.24.7 (stable)]

I am observing a consistent failure of assignment to a global in a unit test that defies debugging, because running the code with the debugger (even without break points set) makes the problem vanish.

I've resorted to console output debugging that you can see a snapshot of below. The key things to know:

  • Multi-threading issues shouldn't be at play here, since the unit test is not explicitly multithreaded
  • Even if multithreading were an issue, the code in question is executed within a synchronized block, $vm_lock is an instance of java.lang.Object, and no other code in the code base accesses $cache_load_number for reading or writing outside of a block synchronized on $vm_lock
  • The test consistently fails incrementing $cache_load_number from 100 to 101, every time.
  • I have tried both $cache_load_number += 1 and $cache_load_number = $cache_load_number + 1 and the results are identical

The output observed, shown in the console log should be impossible:

Cache Load Number: 100 before increment (Fixnum)
Cache Load Number: 100 end of synchronized block (Fixnum)

screen shot 2013-12-31 at 12 32 37 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions