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

Compiling with optimizer enabled breaks code #9

Open
jlfranklin opened this issue Jun 16, 2024 · 1 comment
Open

Compiling with optimizer enabled breaks code #9

jlfranklin opened this issue Jun 16, 2024 · 1 comment

Comments

@jlfranklin
Copy link
Contributor

I ran into two places where the code crashes (SIGILL) when compiled with -O3. Cobble allows debug=true (-O0) or debug=false (-O3), so I can't speak to other optimization levels.

The first is in find_mac(). Adding a LOG("OCTET", i); to the at airplay.cpp:58 keeps the optimizer from breaking the code.

info: Switched to scene 'Scene'
info: ------------------------------------------------
info: Loaded scenes:
info: - scene 'Scene':
info: ------------------------------------------------
[Thread 0x7ffeeeebe6c0 (LWP 2106793) exited]

Thread 1 "obs" received signal SIGILL, Illegal instruction.
0x00007fff821e8906 in find_mac[abi:cxx11]() () at ./airplay.cpp:58
warning: Source file is more recent than executable.
58              if ((octet[i] = s->sll_addr[i]) != 0)
(gdb)

The second is in generate_key_schedule(). I didn't try fixing anything here.

info: User added source 'AirPlay 2' (AirPlay) to scene 'Scene'
./airplay.cpp:401: I Accepted IPv4 client on socket 53
./airplay.cpp:401: I Local: 192.168.1.214
./airplay.cpp:401: I Remote: 192.168.1.102
./airplay.cpp:224: conn_init
./airplay.cpp:229: Open connections: 1

Thread 47 "obs" received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7ffeee6bd6c0 (LWP 2110053)]
0x00007fff8220007a in generate_key_schedule (key_material=<optimized out>, key_schedule=<optimized out>) at UxPlay/lib/playfair/omg_hax.c:179
warning: Source file is more recent than executable.
179           key_data[1] ^= key_data[0];
(gdb)

The find_mac() function is in airplay.cpp, but copied from the UxPlay project. The generate_key_schedule() is part of UxPlay. Note, that UxPlay has moved from where the submodule points (https://github.com/antimof/UxPlay) to https://github.com/FDH2/UxPlay, and has seen considerable development since this was pinned, including support for PIN-based access.

@jlfranklin jlfranklin changed the title Compiling with optimizer enable breaks code Compiling with optimizer enabled breaks code Jun 17, 2024
@mika314
Copy link
Owner

mika314 commented Jul 9, 2024

As a workaround, just update the line in main.cpp of coddle:

      cflags << " -O3" << (cfg.marchNative ? " -march=native" : "");

When I have time, I'll add the config to be able to control the optimization level.

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

No branches or pull requests

2 participants