From 272a82e06acced6a6f78ff9d9ca8802c03f3f3df Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sat, 23 Nov 2019 21:32:41 +0000 Subject: [PATCH] fix(core): update --- .gitlab-ci.yml | 8 ++++++++ stack-fix.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 stack-fix.c diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e2f72d..d940bcc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,14 @@ before_script: - apk add --no-cache libgcc libstdc++ gnupg nodejs nodejs-npm - apk add --no-cache krb5-libs - update-ca-certificates +- cp ./stack-fix.c /lib/ +- set -ex \ + && apk add --no-cache --virtual .build-deps build-base \ + && gcc -shared -fPIC /lib/stack-fix.c -o /lib/stack-fix.so \ + && apk del .build-deps + +# export the environment variable of LD_PRELOAD +ENV LD_PRELOAD /lib/stack-fix.so - npm config set unsafe-perm true - npm install -g @shipzone/npmci - npmci npm prepare diff --git a/stack-fix.c b/stack-fix.c new file mode 100644 index 0000000..49a79ec --- /dev/null +++ b/stack-fix.c @@ -0,0 +1,32 @@ +#include +#include +#include + +// 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; +} \ No newline at end of file