pytorch / cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
BSD 2-Clause "Simplified" License
990 stars 310 forks source link

Missing cpuinfo_deinitialize implementation #150

Open jrosdahl opened 1 year ago

jrosdahl commented 1 year ago

When using ONNX Runtime (which has PyTorch cpuinfo as a static dependency) with a Linux program built with LeakSanitizer/AddressSanitizer, memory leaks are reported:

=================================================================
==11753==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 576 byte(s) in 1 object(s) allocated from:
    #0 0x2b11dd429917 in __interceptor_calloc (/path/to/libasan.so.6+0xb4917)
    #1 0x2b11e45064b6 in cpuinfo_x86_linux_init (/path/to/libonnxruntime.so.1.14.1+0x8684b6)

Direct leak of 576 byte(s) in 1 object(s) allocated from:
    #0 0x2b11dd429917 in __interceptor_calloc (/path/to/libasan.so.6+0xb4917)
    #1 0x2b11e4506496 in cpuinfo_x86_linux_init (/path/to/libonnxruntime.so.1.14.1+0x868496)

SUMMARY: AddressSanitizer: 1152 byte(s) leaked in 2 allocation(s).

ONNX Runtime doesn't call cpuinfo_deinitialize, but on the other hand that wouldn't help since the implementation is empty.

It would be nice if cpuinfo_deinitialize could be implemented so that ONNX Runtime and other users can call it to deallocate the resources.