pytorch / pytorch/cpuinfo

Missing cpuinfo_deinitialize implementation

Open
#150 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
1.2k
Forks
409
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/init.c at the cpuinfo_deinitialize implementation and trace the allocations reported from cpuinfo_x86_linux_init on Linux. Implement cleanup for those resources and verify that calling cpuinfo_deinitialize no longer produces the reported LeakSanitizer or AddressSanitizer leaks.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.