CAS operation fails in readMarshallable()
See original GitHub issueHi, please check this code example:
public void testCAS() {
final File dir = getTmpDir();
try (final SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(dir)
.build()) {
final ExcerptAppender appender = queue.acquireAppender();
final ExcerptTailer tailer = queue.createTailer();
final WriteBytesMarshallable writeBytesMarshallable = bytes -> bytes.writeLong(123L);
final ReadBytesMarshallable readBytesMarshallable = bytes -> bytes.compareAndSwapLong(bytes.readPosition(), 123L, 321L);
final int iterations = 5; // fails at 5th iteration
for (int i = 0; i < iterations; i++) {
appender.writeBytes(writeBytesMarshallable);
tailer.readBytes(readBytesMarshallable);
}
}
}
It fails with exception:
net.openhft.chronicle.core.util.MisAlignedAssertionError at net.openhft.chronicle.core.UnsafeMemory.compareAndSwapLong(UnsafeMemory.java:983) at net.openhft.chronicle.bytes.internal.NativeBytesStore.compareAndSwapLong(NativeBytesStore.java:342) at net.openhft.chronicle.bytes.MappedBytesStore.compareAndSwapLong(MappedBytesStore.java:187) at net.openhft.chronicle.bytes.internal.ChunkedMappedBytes.compareAndSwapLong(ChunkedMappedBytes.java:607) at net.openhft.chronicle.queue.AcquireReleaseTest.lambda$testCAS$5(AcquireReleaseTest.java:147) at net.openhft.chronicle.wire.MarshallableIn.readBytes(MarshallableIn.java:69) at net.openhft.chronicle.queue.AcquireReleaseTest.testCAS(AcquireReleaseTest.java:152)
I guess it is somehow connected with padding/alignment. There were some changes in Chronicle Core library, addressing padding. My environment is Intel Macbook Pro 2013, Oracle JDK 1.8.0_201. Currently we are using 5.21ea44 in production, there is no such problem.
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (7 by maintainers)

Top Related StackOverflow Question
Sorry, I was wrong. To be more precise, I am testing at commit 161dda49bed41df9bdc0e36a261ce2dadcd29611 of ea branch.
Can we close this?