elastic / elastic-otel-java

Apache License 2.0
14 stars 11 forks source link

Bugfix: Prevent process correlation storage from being GCed #114

Closed JonasKunz closed 7 months ago

JonasKunz commented 7 months ago

For the profiling correlation we have a native global variable for providing the profiler with process-level information, e.g. the service name. This global variable points to the native memory contents of a ByteBuffer. Therefore we must ensure that the currently used ByteBuffer is not GCed, otherwise the content to which the native global variable points may become invalid.

JonasKunz commented 7 months ago

Do you think we could add a unit test to ensure keeping the reference is explicitly tested

I initially thought it was hard to test, because we can't now whether the native pointer points into garbage or not. But after some more thinking I came up with a test to simply check that the provided buffer is kept alive.

I've added the testcase