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

fatal error: non-Go code set up signal handler without SA_ONSTACK flag #13

Open
cdevienne opened this issue Feb 5, 2021 · 6 comments
Open

Comments

@cdevienne
Copy link

Using go-libreofficekit I have this error message coming up:

signal 23 received but handler not on signal stack
fatal error: non-Go code set up signal handler without SA_ONSTACK flag

runtime stack:
runtime: unexpected return pc for runtime.sigtramp called from 0x7f25a7ad1228
stack: frame={sp:0xc000078ed8, fp:0xc000078f30} stack=[0xc000070e08,0xc000079208)

To avoid it I had to recompile libreoffice with the following patch:

diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx
index 79721def6c5e..0694fc3c7b26 100644
--- a/sal/osl/unx/signal.cxx
+++ b/sal/osl/unx/signal.cxx
@@ -197,7 +197,7 @@ bool onInitSignal()
 
     struct sigaction act;
     act.sa_sigaction = signalHandlerFunction;
-    act.sa_flags = SA_RESTART | SA_SIGINFO;
+    act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
 
     sigfillset(&(act.sa_mask));

I will attempt to report the problem to the libreoffice project but meanwhile we have a workaround.

@cdevienne
Copy link
Author

I reported the issue to the libreoffice project: https://bugs.documentfoundation.org/show_bug.cgi?id=140189

@echarrod
Copy link

Not ideal, but a workaround I've used is to use Go 1.13.

1.14+ seems to throw this error

@xellDart
Copy link

any new??

@cdevienne
Copy link
Author

The issue in the libreoffice bugtracker is still "UNCONFIRMED", so for now we still use our recompiled libreoffice (and it works well).

I just changed the bug status to "NEW", as I am not the only one to have the issue (see https://wiki.documentfoundation.org/QA/BugReport/fr#Status)

mkozhukh added a commit to xbsoftware/preview that referenced this issue Oct 29, 2021
@tehdiplomat
Copy link

Anyone come up with other choices besides compiling their own libreoffice? I'd like to be able to use Go Modules to vendor packages, and need to make it up to 1.14

@oermoshkin
Copy link
Contributor

I found a workaround and create pull request(#16)
By processing the signal on the C side, and adding a SA_ONSTACK flag.

static void libre_fix_signal(int signum)
{
    struct sigaction st;

    if (sigaction(signum, NULL, &st) < 0) {
        goto fix_signal_error;
    }

    st.sa_flags |= SA_ONSTACK;

    if (sigaction(signum, &st,  NULL) < 0) {
        goto fix_signal_error;
    }
    return;
fix_signal_error:
        fprintf(stderr, "error fixing handler for signal %d", signum);
}

void libre_init()
{
    signal(SIGURG, libre_fix_signal);
}

After importing the library, you need to call the function libre_init()

func init() {
	C.libre_init()
}

In my tests, there is no more panic and the lib works.

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

5 participants