Saturday, September 12, 2020

Fix thread stack base detection in devel/kf5/kjs

I think our current patch to unbreak currentThreadStackBase() is wrong.

pthread_stackseg_np(3):

The pthread_stackseg_np() function returns information about the given
thread's stack. A stack_t is the same as a struct sigaltstack (see
sigaltstack(2)) except the ss_sp variable points to the top of the stack
instead of the base.

The old patch points to the TOP and not to the base(end) of the thread stack.

I see no regressions: 100% tests passed, 0 tests failed out of 1

Feedback, OK?

Rafael


Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/kf5/kjs/Makefile,v
retrieving revision 1.12
diff -u -p -u -p -r1.12 Makefile
--- Makefile 23 Mar 2020 18:01:09 -0000 1.12
+++ Makefile 12 Sep 2020 09:51:18 -0000
@@ -2,6 +2,7 @@

COMMENT = JavaScript/ECMAScript engine for KDE
DISTNAME = kjs-${VERSION}
+REVISION = 0

SHARED_LIBS = KF5JS 5.0
SHARED_LIBS += KF5JSApi 5.0
Index: patches/patch-src_kjs_collector_cpp
===================================================================
RCS file: /cvs/ports/devel/kf5/kjs/patches/patch-src_kjs_collector_cpp,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 patch-src_kjs_collector_cpp
--- patches/patch-src_kjs_collector_cpp 7 Jun 2017 17:03:38 -0000 1.2
+++ patches/patch-src_kjs_collector_cpp 12 Sep 2020 09:51:18 -0000
@@ -8,9 +8,9 @@ Index: src/kjs/collector.cpp
pthread_t thread = pthread_self();
if (stackBase == nullptr || thread != stackThread) {
+#if defined(__OpenBSD__)
-+ stack_t sinfo;
-+ pthread_stackseg_np(thread, &sinfo);
-+ stackBase = sinfo.ss_sp;
++ stack_t ss;
++ pthread_stackseg_np(thread, &ss);
++ stackBase = (void*)((size_t) ss.ss_sp - ss.ss_size);
+#else
pthread_attr_t sattr;
#if HAVE_PTHREAD_NP_H || defined(__NetBSD__)

No comments:

Post a Comment