about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorGergő Móricz <mo.geryy@gmail.com>2021-10-17 21:19:52 +0200
committerGergő Móricz <mo.geryy@gmail.com>2021-10-17 21:19:52 +0200
commite1a2230e9ca654cdd2b4230060a304d792843914 (patch)
treea2ae3df6866b43bd75d4ce706caa2fe04c130d6a /src/libtools
parent82bd4431e6f0a43c28bf4d28d49eeee8b52df8c3 (diff)
downloadbox64-e1a2230e9ca654cdd2b4230060a304d792843914.tar.gz
box64-e1a2230e9ca654cdd2b4230060a304d792843914.zip
Add alignment wrapper to pthread_getattr_np.
This fixes stack corruption when using pthread_getattr_np on
hirsute (Ubuntu 21.04) and libc >=2.33

This should also fix #130.
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/threads.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c
index 81ccba3a..31052118 100755
--- a/src/libtools/threads.c
+++ b/src/libtools/threads.c
@@ -417,6 +417,11 @@ EXPORT int my_pthread_attr_setstackaddr(x64emu_t* emu, pthread_attr_t* attr, voi
 	return pthread_attr_setstack(getAlignedAttr(attr), addr, size);
 	//return pthread_attr_setstackaddr(getAlignedAttr(attr), addr);
 }
+EXPORT int my_pthread_getattr_np(x64emu_t* emu, pthread_t thread_id, pthread_attr_t* attr)
+{
+	(void)emu;
+	return pthread_getattr_np(thread_id, getAlignedAttrWithInit(attr, 0));
+}
 #endif
 
 EXPORT int my_pthread_create(x64emu_t *emu, void* t, void* attr, void* start_routine, void* arg)