Skip to content

Fix the seg fault issue (108) due to mavx CFLAG #150

Open
mamthan wants to merge 3 commits intomasterfrom
mavx_support
Open

Fix the seg fault issue (108) due to mavx CFLAG #150
mamthan wants to merge 3 commits intomasterfrom
mavx_support

Conversation

@mamthan
Copy link
Collaborator

@mamthan mamthan commented Sep 23, 2024

We are able to reproduce the issue #108 with the following build command:

cmake -DCMAKE_C_FLAGS="-mavx" ..
make

Encode command:

./xeve_app -i <input.y4m> -o <output.evc>

Error message:

XEVE: eXtra-fast Essential Video Encoder
Segmentation fault

On passing "-mavx2" as C_Flag (cmake -DCMAKE_C_FLAGS="-mavx" ..), it sets the flag for all files in the project, including the source C files. So, the compiler is creating optimizations which are not handled properly resulting in a segmentation fault.

This PR fixes the issue by updating the CmakeLists.txt files.

with the following build command:
```
cmake -DCMAKE_C_FLAGS="-mavx" ..
make
```
Encode command:
```
./xeve_app -i <input.y4m> -o <output.evc>
```

Error message:
```
XEVE: eXtra-fast Essential Video Encoder
Segmentation fault
```

On passing "-mavx2" as C_Flag (cmake -DCMAKE_C_FLAGS="-mavx" ..), it sets the flag
for all files in the project, including the source C files. So, the compiler is
creating optimizations which are not handled properly resulting in a segmentation fault.

This PR fixes the issue by updating the CmakeLists.txt files.
Copy link
Collaborator

@kpchoi kpchoi left a comment

Choose a reason for hiding this comment

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

Did you check why the 'mavx2' option generate segfault exactly?
Theoretically, it should not have problem even though we set 'mavx2' option to c-code.
There could be some buggy code for AVX2 optimization generated by c-compiler?
If we could find the weak code to avx2 optimization, it would be better to change the code itself rather than adding 'mnoavx2' cflag option.

@dariusz-f
Copy link
Collaborator

Output form gdb:

XEVE: eXtra-fast Essential Video Encoder

Program received signal SIGSEGV, Segmentation fault.
0x00005555555a3732 in xeve_pintra_create ()
(gdb) bt
#0  0x00005555555a3732 in xeve_pintra_create ()
#1  0x0000555555570e8a in xeve_platform_init ()
#2  0x00005555555ea4f5 in xevem_platform_init ()
#3  0x0000555555566658 in xeve_create ()
#4  0x000055555555cc83 in main ()

In debug build and under valgrind it works correctly in my case.

@kpchoi
Copy link
Collaborator

kpchoi commented Nov 11, 2024

@neergil ,
Could check this PR?
It is not recommened to change cflag if it is not issue relating to compile and build issue.

Neeraj Gadgil added 2 commits November 20, 2024 19:04
* Shuffle struct member declaration in XEVE_CTX
* Reorder instructions to introduce latency within `pintra_init_mt()` and `pinter_init_mt()` functions
@kpchoi
Copy link
Collaborator

kpchoi commented Jul 16, 2025

@neergil

I don't understand this code fully, because the code change is weird.
It is required to cross-check the code changes.

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.

4 participants