fzwoch / obs-teleport

An OBS Studio plugin for an open NDI-like replacement. Pretty simple, straight forward. No NDI compatibility in any form.
GNU General Public License v2.0
435 stars 16 forks source link

M1 arm64 deadlock #43

Open fzwoch opened 2 years ago

fzwoch commented 2 years ago

Looks like interacting with the the frontend API is deadlocking/crashing OBS.

Can be reproduced with the following plugin:

package main

// #include <obs-module.h>
// #include <obs-frontend-api.h>
//
// extern void frontend_event_cb(enum obs_frontend_event event, void* data);
//
import "C"
import (
    "log"
    "unsafe"
)

var obsModulePointer *C.obs_module_t

//export obs_module_set_pointer
func obs_module_set_pointer(module *C.obs_module_t) {
    obsModulePointer = module
}

//export obs_current_module
func obs_current_module() *C.obs_module_t {
    return obsModulePointer
}

//export obs_module_ver
func obs_module_ver() C.uint32_t {
    return C.LIBOBS_API_VER
}

//export frontend_event_cb
func frontend_event_cb(event C.enum_obs_frontend_event, data unsafe.Pointer) {
    log.Println("event:", event)
}

//export obs_module_load
func obs_module_load() C.bool {
    C.obs_frontend_add_event_callback(C.obs_frontend_event_cb(unsafe.Pointer(C.frontend_event_cb)), nil)

    return true
}

func main() {}

Could be a Go runtime issue when using cgo. But I have no idea..

fzwoch commented 2 years ago
Process 2159 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000013fe00634 obs-test.so`notok + 4
obs-test.so`notok:
->  0x13fe00634 <+4>:  str    x8, [x8]
    0x13fe00638 <+8>:  b      0x13fe00638               ; <+8>
    0x13fe0063c <+12>: udf    #0x0

obs-test.so`runtime.open_trampoline.abi0:
    0x13fe00640 <+0>:  str    x30, [sp, #-0x10]!
Target 0: (OBS) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x000000013fe00634 obs-test.so`notok + 4
    frame #1: 0x000000013fe00c30 obs-test.so`runtime.sigaltstack_trampoline.abi0 + 32
    frame #2: 0x000000013fdff908 obs-test.so`runtime.asmcgocall.abi0 + 200
    frame #3: 0x000000013fdff908 obs-test.so`runtime.asmcgocall.abi0 + 200
    frame #4: 0x000000013fdff908 obs-test.so`runtime.asmcgocall.abi0 + 200
arcreigh commented 2 years ago

I also believe I am running into this on OBS 28 beta 2 on an M1 mini.

fzwoch commented 1 year ago

I wonder if anyone with a beta of macOS Ventura wants to check if the issue persists.

fzwoch commented 1 year ago

obs-teleport.plugin.zip

kilinbox commented 1 year ago

obs-teleport.plugin.zip

I tried it. OBS will not start after installing the plugin(obs-teleport.plugin).

macOS Ventura 13.0 Beta OBS 28.0.1 arm64

fzwoch commented 1 year ago

Thanks for checking. It does not take us much further - but is a good piece of information.

fzwoch commented 1 year ago

A custom build of OBS with enabled Address-Sanitizer loads the plugin just fine. Without the sanitizer the same crash as above happens.

fzwoch commented 1 year ago

Things are getting wild. With this OBS patch applied it seems to run fine:

--- a/UI/obs-app.cpp
+++ b/UI/obs-app.cpp
@@ -3055,6 +3055,19 @@ void ctrlc_handler(int s)

 int main(int argc, char *argv[])
 {
+#if defined __APPLE__ && defined __arm64__
+    char signalStack[SIGSTKSZ];
+    stack_t ss;
+    memset(&ss, 0, sizeof(ss));
+    ss.ss_sp = signalStack;
+    ss.ss_flags = 0;
+    ss.ss_size = SIGSTKSZ;
+    if (sigaltstack(&ss, NULL) < 0) {
+        perror("sigaltstack");
+        abort();
+    }
+#endif
+
 #ifndef _WIN32
    signal(SIGPIPE, SIG_IGN);

Not sure though whether this breaks any existing signals/signal handlers.

fzwoch commented 1 year ago

Here is a 0.6.1 version of the macOS plugin for M1/M2 if anyone interested. You will need to apply the patch below to OBS Studio and build it yourself to make it work though.

diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp
index 02cf48d6c016a..d1143603f93c0 100644
--- a/UI/obs-app.cpp
+++ b/UI/obs-app.cpp
@@ -3165,13 +3165,28 @@ void ctrlc_handler(int s)
 int main(int argc, char *argv[])
 {
 #ifndef _WIN32
-   signal(SIGPIPE, SIG_IGN);
+   stack_t ss;
+   ss.ss_sp = malloc(SIGSTKSZ);
+   if (ss.ss_sp == NULL) {
+       fprintf(stderr, "ss_sp alloc failed\n");
+       exit(1);
+   }
+   ss.ss_size = SIGSTKSZ;
+   ss.ss_flags = 0;
+   if (sigaltstack(&ss, NULL) < 0) {
+       perror("sigaltstack");
+       exit(1);
+   }

    struct sigaction sig_handler;

-   sig_handler.sa_handler = ctrlc_handler;
+   sig_handler.sa_handler = SIG_IGN;
    sigemptyset(&sig_handler.sa_mask);
-   sig_handler.sa_flags = 0;
+   sig_handler.sa_flags = SA_ONSTACK;
+
+   sigaction(SIGPIPE, &sig_handler, NULL);
+
+   sig_handler.sa_handler = ctrlc_handler;

    sigaction(SIGINT, &sig_handler, NULL);

obs-teleport-0.6.1.zip

fzwoch commented 1 year ago

For everyone trying this out. Please write back your macOS version and hardware configuration, and whether it has been working for you or not. (You didn't have to have the patch applied, I just want to collect information what may be the root cause of the original problem)

jbaylies commented 1 year ago

When launching OBS 29.0.2 native with obs-teleport-0.6.1 or 0.6.5 on m1 mac 13.2.1, OBS bounces in the dock forever and doesn't appear.

fzwoch commented 1 year ago

Yes, this is what thich ticket is about..

I can start up OBS when I connect a 2nd monitor and close my Macbook Air's lid.

Dmitrycroft commented 1 year ago

To date (February 20, 2023), the only fully working option for how you can play on a PC and stream through a macbook m1 is: Download the obs version for intel on a macbook m1 and install this plugin (teleport) according to the instructions. Since the teleport didn’t start through the obs version of apple silicon, I found a way out in installing the obs version for intel, which works great on the M1. Good luck to all! And thanks for the great alternative to the buggy NDI. P.S. If you have no sound through the teleport plugin when recording a video / broadcast from the obs, then just add your audio sources through the teleport filter. This link works flawlessly.

raytorres280 commented 1 year ago

Here is a 0.6.1 version of the macOS plugin for M1/M2 if anyone interested. You will need to apply the patch below to OBS Studio and build it yourself to make it work though.

diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp
index 02cf48d6c016a..d1143603f93c0 100644
--- a/UI/obs-app.cpp
+++ b/UI/obs-app.cpp
@@ -3165,13 +3165,28 @@ void ctrlc_handler(int s)
 int main(int argc, char *argv[])
 {
 #ifndef _WIN32
- signal(SIGPIPE, SIG_IGN);
+ stack_t ss;
+ ss.ss_sp = malloc(SIGSTKSZ);
+ if (ss.ss_sp == NULL) {
+     fprintf(stderr, "ss_sp alloc failed\n");
+     exit(1);
+ }
+ ss.ss_size = SIGSTKSZ;
+ ss.ss_flags = 0;
+ if (sigaltstack(&ss, NULL) < 0) {
+     perror("sigaltstack");
+     exit(1);
+ }

  struct sigaction sig_handler;

- sig_handler.sa_handler = ctrlc_handler;
+ sig_handler.sa_handler = SIG_IGN;
  sigemptyset(&sig_handler.sa_mask);
- sig_handler.sa_flags = 0;
+ sig_handler.sa_flags = SA_ONSTACK;
+
+ sigaction(SIGPIPE, &sig_handler, NULL);
+
+ sig_handler.sa_handler = ctrlc_handler;

  sigaction(SIGINT, &sig_handler, NULL);

obs-teleport-0.6.1.zip

this worked for me thank you

the-maty commented 1 year ago

Hello, how does it look with support for apple silicon? I tried it on my macbook pro with m2 max chip and can't even start obs. I'm really looking forward to a possible fix.

andrewmriv commented 1 year ago

Here is a 0.6.1 version of the macOS plugin for M1/M2 if anyone interested. You will need to apply the patch below to OBS Studio and build it yourself to make it work though.

diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp
index 02cf48d6c016a..d1143603f93c0 100644
--- a/UI/obs-app.cpp
+++ b/UI/obs-app.cpp
@@ -3165,13 +3165,28 @@ void ctrlc_handler(int s)
 int main(int argc, char *argv[])
 {
 #ifndef _WIN32
- signal(SIGPIPE, SIG_IGN);
+ stack_t ss;
+ ss.ss_sp = malloc(SIGSTKSZ);
+ if (ss.ss_sp == NULL) {
+     fprintf(stderr, "ss_sp alloc failed\n");
+     exit(1);
+ }
+ ss.ss_size = SIGSTKSZ;
+ ss.ss_flags = 0;
+ if (sigaltstack(&ss, NULL) < 0) {
+     perror("sigaltstack");
+     exit(1);
+ }

  struct sigaction sig_handler;

- sig_handler.sa_handler = ctrlc_handler;
+ sig_handler.sa_handler = SIG_IGN;
  sigemptyset(&sig_handler.sa_mask);
- sig_handler.sa_flags = 0;
+ sig_handler.sa_flags = SA_ONSTACK;
+
+ sigaction(SIGPIPE, &sig_handler, NULL);
+
+ sig_handler.sa_handler = ctrlc_handler;

  sigaction(SIGINT, &sig_handler, NULL);

obs-teleport-0.6.1.zip

Re-rolling this patch for 29.x version.

diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp
index e0b9d114a..b48a0d11c 100644
--- a/UI/obs-app.cpp
+++ b/UI/obs-app.cpp
@@ -3245,13 +3245,27 @@ void OBSApp::ProcessSigInt(void)
 int main(int argc, char *argv[])
 {
 #ifndef _WIN32
-   signal(SIGPIPE, SIG_IGN);
+   stack_t ss;
+   ss.ss_sp = malloc(SIGSTKSZ);
+   if (ss.ss_sp == NULL) {
+       fprintf(stderr, "ss_sp alloc failed\n");
+       exit(1);
+   }
+   ss.ss_size = SIGSTKSZ;
+   ss.ss_flags = 0;
+   if (sigaltstack(&ss, NULL) < 0) {
+       perror("sigaltstack");
+       exit(1);
+   }

    struct sigaction sig_handler;

-   sig_handler.sa_handler = OBSApp::SigIntSignalHandler;
+   sig_handler.sa_handler = SIG_IGN;
    sigemptyset(&sig_handler.sa_mask);
-   sig_handler.sa_flags = 0;
+   sig_handler.sa_flags = SA_ONSTACK;
+   sigaction(SIGPIPE, &sig_handler, NULL);
+
+   sig_handler.sa_handler = OBSApp::SigIntSignalHandler;

    sigaction(SIGINT, &sig_handler, NULL);

I am on a Mac Studio 2022, M1 Max with 32gb of RAM on MacOS Ventura 13.3.1.

fzwoch commented 1 year ago

Thanks, I haven't noticed they did some changes in that area.

I have updated the original PR here: https://github.com/obsproject/obs-studio/pull/7973

Check the branch here: https://github.com/fzwoch/obs-studio/tree/sigaltstack

Note that I don't expect it to me merged ever.

Apple also does not seem to care about the issue, or they consider it a user-space issue but are not telling.

the-maty commented 1 year ago

Thanks, I haven't noticed they did some changes in that area.

I have updated the original PR here: obsproject/obs-studio#7973

Note that I don't expect it to me merged ever.

Apple also does not seem to care about the issue, or they consider it a user-space issue but are not telling.

Does it mean that I have to edit something inside obs?
Sorry for my stupid questions :)

fzwoch commented 1 year ago

Does it mean that I have to edit something inside obs? Sorry for my stupid questions :)

Yes.

the-maty commented 1 year ago

Does it mean that I have to edit something inside obs? Sorry for my stupid questions :)

Yes.

Is there a guide somewhere? I'm not that experienced.

fzwoch commented 1 year ago

Is there a guide somewhere? I'm not that experienced.

Start here: https://github.com/obsproject/obs-studio/wiki/Build-Instructions-For-Mac

In general you will have to build OBS with the patch in the PR, or the pasted one above applied. It can be quite an en-devour for the inexperienced I guess. But you will have to check OBS guides, or guides for these developer tools in general. It is way out of the scope than I can do here..

andrewmriv commented 1 year ago

Is there a guide somewhere? I'm not that experienced.

Start here: https://github.com/obsproject/obs-studio/wiki/Build-Instructions-For-Mac

In general you will have to build OBS with the patch in the PR, or the pasted one above applied. It can be quite an en-devour for the inexperienced I guess. But you will have to check OBS guides, or guides for these developer tools in general. It is way out of the scope than I can do here..

Agree with this.

If anyone is inexperienced, the Prerequisites sections at the top of the guide might be confusing.

  1. If you are new to this, start by installing Homebrew by following the instructions here. You can use that to install the last 2 listed prerequisites: https://brew.sh/
  2. For xcode, you can download that from the Mac's App Store. If you aren't sure of your Mac version, click the Apple icon at the top left of the screen and then click About this Mac. At the time of writing this, you need to at least be on MacOS 12.0. So if the number listed is lower, consider upgrading to MacOS Ventura.
  3. For CMake, you can install it on your system by running brew install cmake
  4. For CCache, you can install it on your system by running brew install ccache

After that, you can follow the first step from the Configuring Build Project which is cloning the project. Copy the git clone --recursive https://github.com/obsproject/obs-studio.git command into your terminal and then run cd obs-studio to go the new directory from git. Note: It is important that you use the --recursive flag so that all of the submodules are pulled in too.

Run git fetch origin pull/7973/head:bugfix/7973 to pull in the code from fzwoch's PR and put it into a new local branch named bugfix/7973.

Run git checkout bugfix/7973 to switch to the new local branch.

After that, you can continue to follow the steps in the official wiki's instructions without any issues.

My only issue when following the guide was that building from the command line did not work in the Build obs-studio section. When running xcodebuild -configuration <Debug|Release|RelWithDebInfo|MinSizeRel> -scheme obs-studio -parallelizeTargets -destination "generic/platform=macOS,name=Any Mac", I got an error saying:

xcodebuild: error: Unknown build action 'obs-studio'

But to get around that:

  1. Open the build_arm64 folder that is generated from running cmake --preset macos-arm64.
  2. Open the obs-studio.xcodeproj file.
  3. (Optional) If you want the newly generated OBS.app file to go to your Applications folder, click Product at the top, then Scheme and then Choose Scheme and then select install from the list.

I wouldn't mind sharing the build I created, but I'm not sure if that is against the rules or anything.

fzwoch commented 1 year ago

There is also a CI/build-macos.sh script that does the right thing sometimes..

snwfdhmp commented 1 year ago

@andrewmriv can you share ?

the-maty commented 1 year ago

There is also a CI/build-macos.sh script that does the right thing sometimes..

Hello, what script do you mean?

fzwoch commented 1 year ago

It has been removed in the meantime from the OBS repository. Check with the OBS team on how to build OBS for macOS.

charset404 commented 11 months ago

Same problem, this was my last outing, I hate NDI, I'm going to get a capture card at once:

MAC M1, 2020 - Ventura 13.5
OBS 29.0.2 (64 bit)
FinalPrecursor commented 9 months ago

Is this change being pushed to the OBS branch? I would like to see a work around that does not require people to manually build both OBS and the plugin. I am switching to MacOS for streaming and could really use this plugin.

fzwoch commented 9 months ago

I tried getting a fix upstream, but i ran again into issues when trying to remove the signal stack and restoring the old one on exit. Then I hit another documentaion issue on Apple's side and I gave up. But anyone can try getting a proper change upstream..

fzwoch commented 9 months ago

One can do it without patching OBS. It is still annoying though.

  1. Make sure System Integrity Protection is off:

    % csrutil status
    System Integrity Protection status: disabled.

    If it is not check https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection?language=objc

  2. Run OBS with loaded address sanitizer:

    DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib /Applications/OBS.app/Contents/MacOS/OBS

    You will have to check what Xcode version you have installed. So you will need an installation of Xcode. Change the directory for the file location where the sanitizer library is found.

Eventually startup fails with something similar to this:

signal 16 received but handler not on signal stack
mp.gsignal stack [0x106d50000 0x106dd0000], mp.g0 stack [0x16afa0000 0x16b79c000], sp=0x114000058768
fatal error: non-Go code set up signal handler without SA_ONSTACK flag

I guess that can happen since the signals are not properly set up now (which the patch does). Just try again, its seems to be working most of the time for me (but only God knows what impacts this behavior).

Not sure why this signal would sometimes be triggered though, and I'm not sure if it can happen again while OBS is running.. someone will find out?

RadicalRingtail commented 8 months ago

i tried out the workaround mentioned above, and while OBS did open and the plugin loaded, i wasnt able to transmit video via the plugin, nothing would show up in a teleport source (both locally and on another computer)

i was able to receive video from another OBS instance on the other computer though

edit: my bad, i acidentally had NDI enabled at the same time as teleport so it didnt work, got it fully working now, the fix above seems to be stable

RadicalRingtail commented 8 months ago

update: experiencing stability issues with the workaround, the stream isnt always picked up by another OBS instance, and lag issues keep happening as well at random (cant replicate it with changing settings either)

fzwoch commented 8 months ago

Check the logs in the case of stability issues. It could very likely be a network congestion (WLAN?).

There may indeed be a problem on first start where the plugin is not work correctly. I have not found the reason for it happening. It seems to happen after first installation normally. So I blame Apple's security systems - but could very well be a bug in the plugin, but I don't think it is related to this bug or the workaround. I never found a reliable way to trigger it.

animation31 commented 7 months ago

Hey everyone, so I manage to get it to "work"

Here is what I did:

  1. Downloaded the Intel Mac version of OBS from their site. (I have a m2 mac, but try it) As of writing this, version 30.0.0 is what I used. [https://obsproject.com/kb/macos-versions](Check it here)
  2. Downloaded the latest version of Teleport which was 0.7.0
  3. Installed OBS first, then Teleport using the install.command file
  4. Initially, macOS gave me a pop-up saying "Developer cannot verify," just pressed Cancel to open OBS.
  5. Then went to System Settings > Privacy and Security > scroll down and find Security, there were 2 messages regarding OBS and OBS plugin not being permitted to be opened or something (I can't remember at the top of my head), but press ALLOW for both.
  6. Open OBS and hopefully it works.

Now, I tried recording my PC via Teleport on my Macbook Pro, quality is good (set to 90) but the audio was laggy. So I'm going to check my settings on that.

Here is my MBP info btw: Macbook Pro - M2 Pro macOS Sonoma 14.2.1 OBS 30.0.0 (for the Mac), 30.0.2 (for the Windows PC)

Please forgive me as I don't know the proper use of lingo, quotations, etc in Github

fzwoch commented 7 months ago

Yeah, running inside Rosetta is fine. But ideally one could run it natively without the translation layer.

Doty1154 commented 7 months ago

Hey I'm running into this issue on my m1 as well. Here are the log files during startup with the latest plugin release and the latest obs. I started without the plugin as well so you can see the full log logs.zip

please dm me if you want help troubleshooting 1:1

nunowonder commented 6 months ago

Hello all... so I´m one of those NDI users that LOVED to have teleport on his M1 Max machine, but because Teleport didn´t work on OBS M1 version, never really tried. Since yesterday that the NDI plugin just got messed out - there´s tons of people dealing with this and no one knows what´s happening - I really had to make sure I got teleport, and hey, what a BEAST! In spite of I only got it working on OBS Intel version (so it´s not using my resources of M1 Max and not optimized so I need to use more CPU power to have this working), I can tell that Teleport is THE thing! I only needed Alpha Transparency but... well seems that may take some time, so I am working with Color Key. Not ideal, but it makes what it´s needed, of course with a lack of quality but, it´s damn fast and damn good! Great Quality on transmission! My question is: I don´t know how to "build" obs. I´m really noob in that matter. I really don´t know, even following those guides you posted above, how or even what to do. Shall I build an OBS that have the plugins already that I need? and sources and scenes already? And then, I can change something so that teleport is recognized with my M1 OBS version? Or maybe you are just releasing a version that WILL work on M1 computers? Please do.... I truly appreciate that...

fzwoch commented 6 months ago

You should check on the OBS site on how to build it. Instructions constantly change and things here get outdated too quickly.

I don't have a macOS sign key, Twitch API keys etc.. so it makes little sense to build an OBS version without them for distribution. Also it is too much work for me to maintain it. So you will have to go through that yourself.

On Sat, Feb 10, 2024 at 4:42 PM nunowonder @.***> wrote:

Hello all... so I´m one of those NDI users that LOVED to have teleport on his M1 Max machine, but because Teleport didn´t work on OBS M1 version, never really tried. Since yesterday that the NDI plugin just got messed out

  • there´s tons of people dealing with this and no one knows what´s happening - I really had to make sure I got teleport, and hey, what a BEAST! In spite of I only got it working on OBS Intel version (so it´s not using my resources of M1 Max and not optimized so I need to use more CPU power to have this working), I can tell that Teleport is THE thing! I only needed Alpha Transparency but... well seems that may take some time, so I am working with Color Key. Not ideal, but it makes what it´s needed, of course with a lack of quality but, it´s damn fast and damn good! Great Quality on transmission! My question is: I don´t know how to "build" obs. I´m really noob in that matter. I really don´t know, even following those guides you posted above, how or even what to do. Shall I build an OBS that have the plugins already that I need? and sources and scenes already? And then, I can change something so that teleport is recognized with my M1 OBS version? Or maybe you are just releasing a version that WILL work on M1 computers? Please do.... I truly appreciate that...

— Reply to this email directly, view it on GitHub https://github.com/fzwoch/obs-teleport/issues/43#issuecomment-1937046905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADLKNJQ2AZW54YZ64AMGQTYS6IODAVCNFSM547XBYIKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJTG4YDINRZGA2Q . You are receiving this because you authored the thread.Message ID: @.***>

nunowonder commented 6 months ago

@fzwoch Thank you very much for your answer, but what I was asking for was a Teleport version that would work on M1 OBS, not the build itself, that would be asking too much! ehehe :) Anyway, of course having alpha transparency, it it was something you could do easily, would be actually more important than M1 version, because I can work with OBS (intel mode) on my M1, so... Well, I will be here for anything, any tests needed, I can help as you want so we can go through this :)

fzwoch commented 6 months ago

The Teleport version available is all it can do to work on M1. Due to an Apple bug it is not. So it requires a patched OBS version or the workaround loading address sanitizer libraries.

There will be no alpha channel support.

nunowonder commented 6 months ago

Ups I didn´t read about alpha channel. Can I ask why? Sorry it's only because I really don´t know why, because we get it with NDI. If it was like a "filter" on source, or sources, or scenes, that would send instead of Main Output?

fzwoch commented 5 months ago

Here is another workaround that does not require running with Apple's address sanitizer or building a patched OBS version. I'll also attach a binary, so you won't even need Xcode to be installed. Check the SIP note below though!

signalstack.c

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

stack_t stack;

__attribute__((constructor))
void init()
{
    printf("SET UP SIGALTSTACK.. ");
    stack.ss_sp = malloc(SIGSTKSZ);
    if (stack.ss_sp == NULL) {
        printf("ss_sp alloc failed\n");
        exit(1);
    }
    stack.ss_size = SIGSTKSZ;
    stack.ss_flags = 0;
    if (sigaltstack(&stack, NULL) != 0) {
        printf("sigaltstack failed\n");
        exit(1);
    }
    printf("DONE\n");
}

Compile with:

clang -shared signalstack.c -o signalstack.dylib

Run with:

DYLD_INSERT_LIBRARIES=/path/to/signalstack.dylib /Applications/OBS.app/Contents/MacOS/OBS

You will probably still have to tinker with Apple's SIP to allow injection of shared libraries. https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection

Check the output for the SET UP SIGALTSTACK.. DONE line to verify the loading is successful.

signalstack.zip

nunowonder commented 4 months ago

@fzwoch thank you so much for your help! The problem for me is: I don´t understand anything that you wrote... :)

fzwoch commented 3 months ago

As another side note: It works just fine with PRISM Live Studio ¯\(ツ)

Was thinking about another try checking address sanitizer and thread sanitizer.. but OBS Studio does not compile with these options enabled.