Skip to content

Fix missing GC factories when linked as profiling - #111

Merged
gedaiu merged 1 commit into
gedaiu:masterfrom
seeseemelk:patch-1
Oct 19, 2026
Merged

gedaiu merged 1 commit into
gedaiu:masterfrom
seeseemelk:patch-1

Conversation

@seeseemelk

Copy link
Copy Markdown
Contributor

There is a particular bug that can happen when all of these conditions are met:

  • An application links with fluent-asserts
  • The application is build with --build=profile
  • The D Runtime is linked after fluent-asserts into the application.

When a D application is built with profiling enabled, a small profiling wrapper is put around nearly every function. The very first time such a wrapper is executed, it calls rt.trace.trace_init(). This method can (and on my machine does) trigger GC.

If the linking order is unfortunate, this GC call can happen before D's own initializers configure the GC factories. Then, no GC factory can be found, and the following error is printed before the program exits:

No GC was initialized, please recheck the name of the selected GC ('conservative').

By flipping the version-clause, we prevent this one extra wrapper being put this early.

To trigger this bug, use a modern Mac, install LDC via homebrew, and then run in an empty directory:

$ dub init
$ dub add fluent-asserts
$ dub run --build=profile

This should ideally also be fixed in DMD/LDC. It probably should not be placing these wrappers on pragma(crt_constructor) calls. I hope to get that done at some point, but this will unblock me faster.

@gedaiu
gedaiu merged commit a95181c into gedaiu:master Oct 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants