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

SIGSEGV if compiled with -fexceptions #52

Open
Narrat opened this issue Sep 16, 2023 · 0 comments · May be fixed by #53
Open

SIGSEGV if compiled with -fexceptions #52

Narrat opened this issue Sep 16, 2023 · 0 comments · May be fixed by #53

Comments

@Narrat
Copy link

Narrat commented Sep 16, 2023

Hello,
there is a curious case with makepkg from Arch Linux involved.
The default config uses the following build flags:

#-- Compiler and Linker Flags
#CPPFLAGS=""
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"

https://gitlab.archlinux.org/archlinux/packaging/packages/pacman/-/blob/main/makepkg.conf?ref_type=heads#L41

If slurm gets compiled with said -fexceptions it will instantly segfault with SIGSEGV upon executing the binary.
Which seems odd?

-fexceptions

Enable exception handling. Generates extra code needed to propagate exceptions. For some targets, this implies GCC generates frame unwind information for all functions, which can produce significant data size overhead, although it does not affect execution. If you do not specify this option, GCC enables it by default for languages like C++ that normally require exception handling, and disables it for languages like C that do not normally require it. However, you may need to enable this option when compiling C code that needs to interoperate properly with exception handlers written in C++. You may also wish to disable this option if you are compiling older C++ programs that don’t use exception handling.

https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fexceptions

So it shouldn't be the cause, as this a C based program? But somehow it is.
And maybe it's related to the various warnings from the compiler?

[1/2] Compiling C object slurm.p/slurm.c.o
In file included from ../slurm-upstream-0.4.4/slurm.c:57:
../slurm-upstream-0.4.4/src/linux.c: In function ‘get_stat’:
../slurm-upstream-0.4.4/src/linux.c:66:5: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   66 |     fgets(buffer, BUFSIZ - 1, proc_net_dev);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../slurm-upstream-0.4.4/src/linux.c:67:5: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   67 |     fgets(buffer, BUFSIZ - 1, proc_net_dev);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../slurm-upstream-0.4.4/slurm.c: In function ‘slurm_shutdown’:
../slurm-upstream-0.4.4/slurm.c:1539:5: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 1539 |     system("clear");
      |     ^~~~~~~~~~~~~~~
../slurm-upstream-0.4.4/slurm.c: In function ‘update_stat_large’:
../slurm-upstream-0.4.4/slurm.c:414:41: warning: iteration 76 invokes undefined behavior [-Waggressive-loop-optimizations]
  414 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                            ~~~~~~~~~~~~~^~~~~~~
../slurm-upstream-0.4.4/slurm.c:413:33: note: within this loop
  413 |     for (x = GRAPH_WIDTH - 1; x >= 0; x--) {
      |                               ~~^~~~
../slurm-upstream-0.4.4/slurm.c: In function ‘update_stat_split’:
../slurm-upstream-0.4.4/slurm.c:700:41: warning: iteration 76 invokes undefined behavior [-Waggressive-loop-optimizations]
  700 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                            ~~~~~~~~~~~~~^~~~~~~
../slurm-upstream-0.4.4/slurm.c:699:38: note: within this loop
  699 |     for (x = GRAPHSPLIT_WIDTH - 1; x >= 0; x--) {
      |                                    ~~^~~~
../slurm-upstream-0.4.4/slurm.c: In function ‘update_stat_combined’:
../slurm-upstream-0.4.4/slurm.c:946:41: warning: iteration 76 invokes undefined behavior [-Waggressive-loop-optimizations]
  946 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                            ~~~~~~~~~~~~~^~~~~~~
../slurm-upstream-0.4.4/slurm.c:945:41: note: within this loop
  945 |     for (x = GRAPHCOMBINED_WIDTH - 1; x >= 0; x--) {
      |                                       ~~^~~~
[2/2] Linking target slurm
In function ‘update_stat_combined’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1492:16:
../slurm-upstream-0.4.4/slurm.c:946:41: warning: iteration 76 invokes undefined behavior [-Waggressive-loop-optimizations]
  946 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                                         ^
../slurm-upstream-0.4.4/slurm.c:945:41: note: within this loop
  945 |     for (x = GRAPHCOMBINED_WIDTH - 1; x >= 0; x--) {
      |                                         ^
In function ‘update_stat_split’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1495:16:
../slurm-upstream-0.4.4/slurm.c:700:41: warning: iteration 76 invokes undefined behavior [-Waggressive-loop-optimizations]
  700 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                                         ^
../slurm-upstream-0.4.4/slurm.c:699:38: note: within this loop
  699 |     for (x = GRAPHSPLIT_WIDTH - 1; x >= 0; x--) {
      |                                      ^
In function ‘update_stat_large’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1498:16:
../slurm-upstream-0.4.4/slurm.c:414:41: warning: iteration 76 invokes undefined behavior [-Waggressive-loop-optimizations]
  414 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                                         ^
../slurm-upstream-0.4.4/slurm.c:413:33: note: within this loop
  413 |     for (x = GRAPH_WIDTH - 1; x >= 0; x--) {
      |                                 ^
In function ‘update_stat_combined’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1492:16:
../slurm-upstream-0.4.4/slurm.c:946:26: warning: ‘__builtin_memmove’ reading 308 bytes from a region of size 0 [-Wstringop-overread]
  946 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                          ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:181:7: note: at offset -4 into source object ‘rx_speedarray’ of size 308
  181 | float rx_speedarray[GRAPHSPLIT_WIDTH];
      |       ^
In function ‘update_stat_combined’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1492:16:
../slurm-upstream-0.4.4/slurm.c:947:26: warning: ‘__builtin_memmove’ reading 308 bytes from a region of size 0 [-Wstringop-overread]
  947 |         tx_speedarray[x] = tx_speedarray[x - 1];
      |                          ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:187:7: note: at offset -4 into source object ‘tx_speedarray’ of size 308
  187 | float tx_speedarray[GRAPHSPLIT_WIDTH];
      |       ^
In function ‘update_stat_combined’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1492:16:
../slurm-upstream-0.4.4/slurm.c:949:28: warning: ‘__builtin_memmove’ reading 3696 bytes from a region of size 0 [-Wstringop-overread]
  949 |             rx_graph[x][y] = rx_graph[x - 1][y];
      |                            ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:180:5: note: at offset -48 into source object ‘rx_graph’ of size 3696
  180 | int rx_graph[GRAPHSPLIT_WIDTH][GRAPHCOMBINED_HEIGHT];
      |     ^
In function ‘update_stat_combined’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1492:16:
../slurm-upstream-0.4.4/slurm.c:950:28: warning: ‘__builtin_memmove’ reading 3696 bytes from a region of size 0 [-Wstringop-overread]
  950 |             tx_graph[x][y] = tx_graph[x - 1][y];
      |                            ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:186:5: note: at offset -48 into source object ‘tx_graph’ of size 3696
  186 | int tx_graph[GRAPHSPLIT_WIDTH][GRAPHCOMBINED_HEIGHT];
      |     ^
In function ‘update_stat_split’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1495:16:
../slurm-upstream-0.4.4/slurm.c:700:26: warning: ‘__builtin_memmove’ reading 308 bytes from a region of size 0 [-Wstringop-overread]
  700 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                          ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:181:7: note: at offset -4 into source object ‘rx_speedarray’ of size 308
  181 | float rx_speedarray[GRAPHSPLIT_WIDTH];
      |       ^
In function ‘update_stat_split’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1495:16:
../slurm-upstream-0.4.4/slurm.c:701:26: warning: ‘__builtin_memmove’ reading 308 bytes from a region of size 0 [-Wstringop-overread]
  701 |         tx_speedarray[x] = tx_speedarray[x - 1];
      |                          ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:187:7: note: at offset -4 into source object ‘tx_speedarray’ of size 308
  187 | float tx_speedarray[GRAPHSPLIT_WIDTH];
      |       ^
In function ‘update_stat_large’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1498:16:
../slurm-upstream-0.4.4/slurm.c:414:26: warning: ‘__builtin_memmove’ reading 308 bytes from a region of size 0 [-Wstringop-overread]
  414 |         rx_speedarray[x] = rx_speedarray[x - 1];
      |                          ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:181:7: note: at offset -4 into source object ‘rx_speedarray’ of size 308
  181 | float rx_speedarray[GRAPHSPLIT_WIDTH];
      |       ^
In function ‘update_stat_large’,
    inlined from ‘update_stat.isra’ at ../slurm-upstream-0.4.4/slurm.c:1498:16:
../slurm-upstream-0.4.4/slurm.c:415:26: warning: ‘__builtin_memmove’ reading 308 bytes from a region of size 0 [-Wstringop-overread]
  415 |         tx_speedarray[x] = tx_speedarray[x - 1];
      |                          ^
../slurm-upstream-0.4.4/slurm.h: In function ‘update_stat.isra’:
../slurm-upstream-0.4.4/slurm.h:187:7: note: at offset -4 into source object ‘tx_speedarray’ of size 308
  187 | float tx_speedarray[GRAPHSPLIT_WIDTH];
      |       ^
@Iksas Iksas linked a pull request Aug 30, 2024 that will close this issue
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 a pull request may close this issue.

1 participant