mika314 / obs-airplay

OBS plugin to capture screen mirroring from iOS and macOS devices
GNU General Public License v2.0
43 stars 9 forks source link

Compiling with optimizer enabled breaks code #9

Open jlfranklin opened 4 months ago

jlfranklin commented 4 months ago

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.

mika314 commented 3 months ago

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.