You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.NET 8 raises System.AccessViolationException when Org.Apache.Kafka.Streams.KeyValue<K, V> is retrieved from Org.Apache.Kafka.Streams.State.KeyValueIterator<K, V>#345
Describe the bug
Under .NET 8 environment Org.Apache.Kafka.Streams.State.KeyValueIterator<K, V> many times raises System.AccessViolationException when Org.Apache.Kafka.Streams.KeyValue<K, V> is retrieved
masesdevelopers
changed the title
.NET 8 raises System.AccessViolationException when KeyValue<K, V> is retrieved from KeyValueIterator<K, V>
.NET 8 raises System.AccessViolationException when Org.Apache.Kafka.Streams.KeyValue<K, V> is retrieved from Org.Apache.Kafka.Streams.State.KeyValueIterator<K, V>Jan 16, 2024
Seems that the .NET Garbage Collector retires the Org.Apache.Kafka.Streams.KeyValue<K, V> object, releasing the underlying JVM object; this implies that the pointer stored is no more valid and the access to the data raises the exception. A possible workaround can be to instruct the .NET Garbage Collector to stop its execution around the critical region using GC.TryStartNoGCRegion ending it with GC.EndNoGCRegion:
#if NET8_0boolstartedGCRegion=false;startedGCRegion=GC.TryStartNoGCRegion(1024,false);
#endif
// critical region
#if NET8_0if(startedGCRegion&&GCSettings.LatencyMode==GCLatencyMode.NoGCRegion)GC.EndNoGCRegion();
#endif
The memory, in the previous example is 1024, can be changed based on the application using the Org.Apache.Kafka.Streams.State.KeyValueIterator<K, V>, the second parameter is set to false to avoid an usefulness full GC.
Describe the bug
Under .NET 8 environment
Org.Apache.Kafka.Streams.State.KeyValueIterator<K, V>
many times raisesSystem.AccessViolationException
whenOrg.Apache.Kafka.Streams.KeyValue<K, V>
is retrievedTo Reproduce
See masesgroup/KEFCore#194
Expected behavior
Since in .NET 6 and .NET 7 the issue is not raised, the expectation is the same for .NET 8
Screenshots
N/A
Desktop (please complete the following information):
Additional context
See masesgroup/KEFCore#194
The text was updated successfully, but these errors were encountered: