QiuYucheng2003 opened a new issue, #4401:
URL: https://github.com/apache/carbondata/issues/4401

   ### Summary
   
   The CSDK wrappers store JNI local references as members and leave several 
temporary references unreleased.
   
   Affected code:
   
   - 
https://github.com/apache/carbondata/blob/f86ac085ddbbd8381b0a5b65658731fe618eff4a/sdk/CSDK/src/CarbonSchemaReader.cpp
   - 
https://github.com/apache/carbondata/blob/f86ac085ddbbd8381b0a5b65658731fe618eff4a/sdk/CSDK/src/Configuration.cpp
   
   ### Issues
   
   - `FindClass` results are stored in `carbonSchemaReaderClass` and 
`configurationClass` without `NewGlobalRef`.
   - `configurationObject` is also stored as a member local reference.
   - Temporary strings created by `NewStringUTF` in `readSchema`, `set`, and 
`get` are not released.
   - `Configuration::get` returns data from `GetStringUTFChars` without calling 
`ReleaseStringUTFChars`.
   
   ### Impact
   
   If these C++ objects survive beyond the current JNI frame, their member 
references become invalid. Repeated calls on a long-lived attached thread may 
also accumulate local references and native string buffers, potentially causing 
failures or crashes.
   
   ### Suggested fix
   
   - Convert persistent member references with `NewGlobalRef` and release them 
with `DeleteGlobalRef` in destructors.
   - Define safe copy/move ownership semantics for these wrappers.
   - Delete temporary local references after JNI calls.
   - Copy the value returned by `GetStringUTFChars` into owned memory, then 
call `ReleaseStringUTFChars` before returning.


-- 
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]

Reply via email to