microsoft / microsoft/DirectXShaderCompiler

Lifetime of dynamic-library related resources, tied to static object instance.

Open
#7,383 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
Specifically on Linux platform.
Dynamic memory allocations by dxil are released when the dynamic library is released.
A quick look in the DXC source appears to show this happens in the destructor of a static object instance in DXC.

This causes issues when doing custom memory management (memory leaks reported).
Also, by the time those allocations are freed (app exit), the custom memory-manager no longer exists. Causing a segmentation fault.

On Windows platform this is not an issue because the lifetime of the static is bound to the DXC DLL whereas on Linux the dxil dynamic-library appears to be loaded in global space.

Steps to Reproduce
On Linux:

  • Overload global new operator and count allocations
  • Initialize DXC
  • Use DXC API
  • Close and release DXC
  • Check allocation count (Count > 0)
  • Exit app

Actual Behavior
Not all allocations are freed after closing and releasing DXC.

Environment

  • DXC version 2025.02.20
  • Host Operating System Ubuntu, ArchLinux

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

No source files or tests are named. Start by reproducing the Linux allocation-count scenario, then trace DXC and dxil dynamic-library teardown to identify where the remaining allocations are released. Done means resources are released before the custom memory manager is destroyed, with no leak count or exit-time segmentation fault.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
compilers, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.