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

CMakeLists.txt: define APFEL_VERSION, like in config.h.in #53

Merged
merged 3 commits into from
Dec 9, 2023
Merged

CMakeLists.txt: define APFEL_VERSION, like in config.h.in #53

merged 3 commits into from
Dec 9, 2023

Conversation

veprbl
Copy link
Contributor

@veprbl veprbl commented Dec 9, 2023

This fixes a crash observed in builds with either -fsanitize=address or -fstack-protector. ASAN is enabled on CI on Linux to help catch such issues. Version reported in the welcome message is corrected along the way.

The issue was that 6 byte apfelversion variable is overwritten with an uninitialized macro "APFEL_VERSION":

==4268==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f7b07a00026 at pc 0x7f7bea200176 bp 0x7fff03f0df90 sp 0x7fff03f0d750
WRITE of size 14 at 0x7f7b07a00026 thread T0
    #0 0x7f7bea200175 in __interceptor_strncpy (/lib64/libasan.so.8+0xa7175) (BuildId: 7fcb7759bc17ef47f9682414b6d99732d6a6ab0c)
    #1 0x7f7b09a7196b in getapfelversion_ (/__w/apfel/apfel/BUILD/lib64/libAPFEL.so.0.0.0+0x7196b) (BuildId: 97c5a5b3dd9338763c1a566b1d40726fa5188c3c)
    #2 0x7f7b09a762eb in welcomemessage_ (/__w/apfel/apfel/BUILD/lib64/libAPFEL.so.0.0.0+0x762eb) (BuildId: 97c5a5b3dd9338763c1a566b1d40726fa5188c3c)
    #3 0x7f7b09a9a7b6 in reportparameters_ (/__w/apfel/apfel/BUILD/lib64/libAPFEL.so.0.0.0+0x9a7b6) (BuildId: 97c5a5b3dd9338763c1a566b1d40726fa5188c3c)
    #4 0x7f7b09a8d55c in initializeapfel_ (/__w/apfel/apfel/BUILD/lib64/libAPFEL.so.0.0.0+0x8d55c) (BuildId: 97c5a5b3dd9338763c1a566b1d40726fa5188c3c)
    #5 0x4024fa in main (/__w/apfel/apfel/BUILD/examples/Timing+0x4024fa) (BuildId: b00384fea5f68a2087b87c11453e4a22a286f1b6)
    #6 0x7f7b095f2149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId: 788cdd41a15985bf8e0a48d213a46e07d58822df)
    #7 0x7f7b095f220a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId: 788cdd41a15985bf8e0a48d213a46e07d58822df)
    #8 0x402c44 in _start (/__w/apfel/apfel/BUILD/examples/Timing+0x402c44) (BuildId: b00384fea5f68a2087b87c11453e4a22a286f1b6)

Address 0x7f7b07a00026 is located in stack of thread T0 at offset 38 in frame
    #0 0x7f7b09a760bf in welcomemessage_ (/__w/apfel/apfel/BUILD/lib64/libAPFEL.so.0.0.0+0x760bf) (BuildId: 97c5a5b3dd9338763c1a566b1d40726fa5188c3c)

  This frame has 11 object(s):
    [32, 38) 'apfelversion' (line 10) <== Memory access at offset 38 overflows this variable

@scarrazza
Copy link
Owner

Thank you @veprbl.

@scarrazza scarrazza merged commit 8be0c3b into scarrazza:master Dec 9, 2023
2 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