clee704 opened a new pull request, #11532:
URL: https://github.com/apache/incubator-gluten/pull/11532
## What changes were proposed in this pull request?
Add `google::protobuf::ShutdownProtobufLibrary()` call at the end of
`JNI_OnUnload()` to properly clean up protobuf's static internal data
structures when the JNI library is unloaded.
## Why are the changes needed?
When running tests with LeakSanitizer enabled, a memory leak is detected:
```
==4790==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 88 byte(s) in 1 object(s) allocated from:
#0 operator new(unsigned long) asan_new_delete.cpp
#1 gluten::ConfigMap::_InternalParse (libgluten.so+0x9ebd49)
```
Gluten uses protobuf for parsing `ConfigMap` and Substrait plans. When the
protobuf library initializes, it creates static internal data structures.
According to the [protobuf
documentation](https://protobuf.dev/reference/cpp/api-docs/google.protobuf.message_lite/),
dynamically-loaded libraries that use protobuf must call
`google::protobuf::ShutdownProtobufLibrary()` during cleanup to free these
static-duration objects when the library is unloaded.
## Does this PR introduce _any_ user-facing change?
No. This only adds cleanup code that runs during library unload.
## How was this patch tested?
The fix resolves the LeakSanitizer report mentioned above.
Closes #11531
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]