fix: Increase robustness of function-local static initialization for certain injector behaviors #491

Open
ELDment wants to merge 1 commit from ELDment/main into main
ELDment commented 2026-03-14 16:06:25 +01:00 (Migrated from github.com)

During dump generation, a fatal crash was observed, which was traced back to the initialization of function-local static std::unordered_map

d60f2ec28e283c91dcde1be28d8bf3fc

Upon further investigation, it appears the root cause is that certain manual-mapping injectors do not properly handle the CRT's initialization routines


b7cc0615db24fd51602dfe27eaf5a9c5

By moving these variables to file scope, we sidestep the runtime initialization path that requires complex guard logic from the injector

During dump generation, a fatal crash was observed, which was traced back to the initialization of function-local static `std::unordered_map` <img width="1105" height="510" alt="d60f2ec28e283c91dcde1be28d8bf3fc" src="https://github.com/user-attachments/assets/1fb4a5db-661e-444f-b18c-f1a9d6f05eda" /> Upon further investigation, it appears the root cause is that certain manual-mapping injectors do not properly handle the CRT's initialization routines --- <img width="980" height="510" alt="b7cc0615db24fd51602dfe27eaf5a9c5" src="https://github.com/user-attachments/assets/c8b50610-4b12-4eb8-bd19-181aada3aa52" /> By moving these variables to file scope, we sidestep the runtime initialization path that requires complex guard logic from the injector
Fischsalat commented 2026-03-22 00:13:22 +01:00 (Migrated from github.com)

I'll test and merge this pr soon. Which injector did you have this issue with? I've only seen crashes due to improperly initialized static variables in injectors that didn't properly initialize them. When using a normal load library injector I've never had that issue.

I'll test and merge this pr soon. Which injector did you have this issue with? I've only seen crashes due to improperly initialized static variables in injectors that didn't properly initialize them. When using a normal load library injector I've never had that issue.
ELDment commented 2026-03-22 03:46:32 +01:00 (Migrated from github.com)

Which injector did you have this issue with?

heya, @Fischsalat

I’m using the master131/ExtremeInjector with the following configuration

图片
> Which injector did you have this issue with? heya, @Fischsalat I’m using the [master131/ExtremeInjector](https://github.com/master131/ExtremeInjector) with the following configuration <img width="780" height="370" alt="图片" src="https://github.com/user-attachments/assets/4d125817-d633-47b4-a55c-0c4aa5589b5f" />
Fischsalat commented 2026-03-22 13:16:15 +01:00 (Migrated from github.com)

Ok, you're manual mapping so there's a really high chance the injector just isn't properly initializing the variables, rather than MSVC being bugged.

Ok, you're manual mapping so there's a really high chance the injector just isn't properly initializing the variables, rather than MSVC being bugged.
ELDment commented 2026-03-22 13:20:17 +01:00 (Migrated from github.com)

Ok, you're manual mapping so there's a really high chance the injector just isn't properly initializing the variables, rather than MSVC being bugged.

@Fischsalat
Oh, totally possible you're right about that
Btw, mind merging this PR that initializes variables more conservatively?

> Ok, you're manual mapping so there's a really high chance the injector just isn't properly initializing the variables, rather than MSVC being bugged. @Fischsalat Oh, totally possible you're right about that Btw, mind merging this PR that initializes variables more conservatively?
Fischsalat commented 2026-03-22 19:56:00 +01:00 (Migrated from github.com)

Do you mean this one? Yea I can merge it after I've tested it.

Do you mean this one? Yea I can merge it after I've tested it.
ELDment commented 2026-03-23 03:31:12 +01:00 (Migrated from github.com)

Do you mean this one? Yea I can merge it after I've tested it.

@Fischsalat
alrightly, take your time

> Do you mean this one? Yea I can merge it after I've tested it. @Fischsalat alrightly, take your time
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin ELDment/main:ELDment/main
git switch ELDment/main

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff ELDment/main
git switch ELDment/main
git rebase main
git switch main
git merge --ff-only ELDment/main
git switch ELDment/main
git rebase main
git switch main
git merge --no-ff ELDment/main
git switch main
git merge --squash ELDment/main
git switch main
git merge --ff-only ELDment/main
git switch main
git merge ELDment/main
git push origin main
Sign in to join this conversation.
No description provided.