1
0
mirror of https://github.com/funamitech/mastodon synced 2024-11-25 15:46:44 +09:00
YuruToot/stack-fix.c
David Yip f13ebd02c9
dockerfile: Give more stack space to /sbin/tini.
/sbin/tini ends up running the Sass compiler, which seems to need a
larger thread stack size than the musl default.  This patch incorporates
a fix from
https://raw.githubusercontent.com/jubel-han/dockerfiles/master/common/stack-fix.c,
as described in https://github.com/sass/node-sass/issues/2031.
2018-01-11 04:09:16 -06:00

33 lines
921 B
C

#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
// THIS IS TO AVOID A SIGFAULT WHEN RUNNING python3.6 manage.py runserver
// This should be fixed at some point by Alpine and/or Python
// Check this issue for more info
// https://github.com/docker-library/python/issues/211
typedef int (*func_t)(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg);
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) {
pthread_attr_t local;
int used = 0, ret;
if (!attr) {
used = 1;
pthread_attr_init(&local);
attr = &local;
}
pthread_attr_setstacksize((void*)attr, 2 * 1024 * 1024); // 2 MB
func_t orig = (func_t)dlsym(RTLD_NEXT, "pthread_create");
ret = orig(thread, attr, start_routine, arg);
if (used) {
pthread_attr_destroy(&local);
}
return ret;
}