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

Better fix for when CFLAGS includes -D_FORTIFY_SOURCE #226

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tornaria
Copy link
Contributor

@tornaria tornaria commented Feb 9, 2025

The module signals.pyx has to be built with fortify disabled, because of
a false positive in one of the longjmp(), more precisely in the call

cylongjmp(trampoline_setup, 1)

which appears in setup_trampoline().

Often distributions will add -D_FORTIFY_SOURCE=2 to CFLAGS, and so
this has to be overridden when compiling signals.pyx by adding
-U_FORTIFY_SOURCE to the compiler arguments. The former solution,
using add_project_arguments() doesn't work since it will add flags
before the ones provided in CFLAGS.

Instead, add -U_FORTIFY_SOURCE to the arguments in the definition of
the extension module signal, which will add it to the command line
after the ones provided in CFLAGS. In addition, fortify is disabled
only for building signal.pyx.

The module signals.pyx has to be built with fortify disabled, because of
a false positive in one of the `longjmp()`, more precisely in the call
```
cylongjmp(trampoline_setup, 1)
```
which appears in `setup_trampoline()`.

Often distributions will add `-D_FORTIFY_SOURCE=2` to `CFLAGS`, and so
this has to be overridden when compiling `signals.pyx` by adding
`-U_FORTIFY_SOURCE` to the compiler arguments. The former solution,
using `add_project_arguments()` doesn't work since it will add flags
*before* the ones provided in `CFLAGS`.

Instead, add `-U_FORTIFY_SOURCE` to the arguments in the definition of
the extension module `signal`, which will add it to the command line
*after* the ones provided in `CFLAGS`. In addition, fortify is disabled
only for building `signal.pyx`.
@tornaria tornaria requested a review from tobiasdiez February 16, 2025 13:30
Copy link
Contributor

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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