By: Ricardo B (ricardo.b.delete@this.xxxxx.xx), October 19, 2006 2:23 pm
Room: Moderated Discussions
Tzvetan Mikov (tmikov@gmail.com) on 10/19/06 wrote:
---------------------------
>That's not the point at all. Sorry if I wasn't clear.
>That kind of thing can cause the JVM to crash. A programming error in a safe language
>isn't supposed to be able to do that.
Ah..
JVMs are supposed to be implemented in such way that such code doesn't crash them.
Are you assuming you can crash a JVM with such code?
>The question is : how is that problem solved ? Isn't the solution too expensive ?
>
The details will depend on the garbage collecting scheme used by the JVM, of which I am blissfully ignorant.
But I can speculate it includes some amount of synchronization and/or strong memory ordering arround object allocation and initialization.
As for costs, on x86(-64), normal stores already have strong ordering semantics.
>(A smaller secondary point is that the Java libraries distributed by Sun have this
>bug, but that is really a different and not that interesting subject)
It's only a bug if m_cachedResult isn't declared as volatile. Is it?
---------------------------
>That's not the point at all. Sorry if I wasn't clear.
>That kind of thing can cause the JVM to crash. A programming error in a safe language
>isn't supposed to be able to do that.
Ah..
JVMs are supposed to be implemented in such way that such code doesn't crash them.
Are you assuming you can crash a JVM with such code?
>The question is : how is that problem solved ? Isn't the solution too expensive ?
>
The details will depend on the garbage collecting scheme used by the JVM, of which I am blissfully ignorant.
But I can speculate it includes some amount of synchronization and/or strong memory ordering arround object allocation and initialization.
As for costs, on x86(-64), normal stores already have strong ordering semantics.
>(A smaller secondary point is that the Java libraries distributed by Sun have this
>bug, but that is really a different and not that interesting subject)
It's only a bug if m_cachedResult isn't declared as volatile. Is it?