Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: disable unity mode with Windows Unicode + TrackMemory #12005

Closed
wants to merge 1 commit into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Oct 2, 2023

"TrackMemory" is ENABLE_DEBUG=ON (aka ENABLE_CURLDEBUG=ON,
aka -DCURLDEBUG).

There is an issue with memory tracking and Unicode when built in "unity"
mode, which results in the curl tool crashing right on startup, even
without any command-line option. Interestingly this doesn't happen under
WINE (at least on the system I tested this on), but consistenly happens
on real Windows machines. Crash is 0xC0000374 heap corruption. Both
shared and static curl executables are affected.

This limitation probably won't hit too many people, but it remains
a TODO to find and fix the root cause and drop this workaround.

Example builds and runs:
https://ci.appveyor.com/project/curlorg/curl/builds/48169111/job/17cptxhtpubd7iwj#L313 (static)
https://ci.appveyor.com/project/curlorg/curl/builds/48169111/job/76e1ge758tbyqu9c#L317 (shared)

Follow-up to 3f8fc25 #11095

Ref: #11928
Closes #12005

"TrackMemory" is `ENABLE_DEBUG=ON` (aka `ENABLE_CURLDEBUG=ON`,
aka `-DCURLDEBUG`).

There is an issue with memory tracking and Unicode when build in "unity"
mode, which results in the curl tool crashing right on startup, even
without any command-line option. Interestingly this doesn't happen under
WINE (at least on the system I tested this on), but consistenly happens
on real Windows machines. Crash is 0xC0000374 heap corruption. Both
shared and static curl executables are affected.

This limitation probably won't hit too many people, but it remains
a TODO to find and fix the root cause and drop this workaround.

Example builds and runs:
https://ci.appveyor.com/project/curlorg/curl/builds/48169111/job/17cptxhtpubd7iwj#L313 (static)
https://ci.appveyor.com/project/curlorg/curl/builds/48169111/job/76e1ge758tbyqu9c#L317 (shared)

Follow-up to 3f8fc25 curl#11095

Ref curl#11928
Closes #xxxxx
@vszakats vszakats added cmake Windows Windows-specific unicode Unicode, code page, character encoding labels Oct 2, 2023
@github-actions github-actions bot added the build label Oct 2, 2023
@vszakats vszakats added the tests label Oct 2, 2023
@vszakats vszakats closed this in d82b080 Oct 2, 2023
@vszakats vszakats deleted the cmake-debug-unicode-no-unity branch October 2, 2023 23:29
@vszakats vszakats changed the title cmake: disable unity mode with Windows Unicode + TrackMemory cmake: disable unity with Windows Unicode + TrackMemory Oct 2, 2023
@vszakats vszakats changed the title cmake: disable unity with Windows Unicode + TrackMemory cmake: disable unity mode with Windows Unicode + TrackMemory Oct 2, 2023
vszakats added a commit to vszakats/curl that referenced this pull request Oct 3, 2023
Found the root cause of the startup crash with unity builds with Unicode
and TrackMemory enabled at the same time.

We must make sure that the `memdebug.h` header doesn't apply to
`lib/curl_multibyte.c` (as even noted in a comment there.). In unity
builds all headers apply to all sources, including `curl_multibyte.c`.
This probably resulted in an infinite loop on startup.

This patch excludes this source from unity compilation with TrackMemory
enabled, in both libcurl and curl tool. Also delete the earlier
workaround that fully disabled unity for affected builds.

Also enable unity mode for a debug unicode CI job.

Follow-up to d82b080 curl#12005

Closes curl#11928
vszakats added a commit to vszakats/curl that referenced this pull request Oct 3, 2023
Found the root cause of the startup crash with unity builds with Unicode
and TrackMemory enabled at the same time.

We must make sure that the `memdebug.h` header doesn't apply to
`lib/curl_multibyte.c` (as even noted in a comment there.). In unity
builds all headers apply to all sources, including `curl_multibyte.c`.
This probably resulted in an infinite loop on startup.

This patch excludes this source from unity compilation with TrackMemory
enabled, in both libcurl and curl tool. Also delete the earlier
workaround that fully disabled unity for affected builds.

Also enable unity mode for a debug unicode CI job.

Follow-up to d82b080 curl#12005
Follow-up to 3f8fc25 curl#11095

Closes curl#11928
vszakats added a commit that referenced this pull request Oct 3, 2023
Found the root cause of the startup crash in unity builds with Unicode
and TrackMemory enabled at the same time.

We must make sure that the `memdebug.h` header doesn't apply to
`lib/curl_multibyte.c` (as even noted in a comment there.) In unity
builds all headers apply to all sources, including `curl_multibyte.c`.
This probably resulted in an infinite loop on startup.

Exclude this source from unity compilation with TrackMemory enabled,
in both libcurl and curl tool. Enable unity mode for a debug Unicode
CI job to keep it tested. Also delete the earlier workaround that
fully disabled unity for affected builds.

Follow-up to d82b080 #12005
Follow-up to 3f8fc25 #11095

Closes #11928
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build cmake tests unicode Unicode, code page, character encoding Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

None yet

1 participant