pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

Segfaulting on microcontainers

Open terminalsin opened this issue 8 months ago • 6 comments

  • [x] I am on the latest Pendulum version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: ghcr.io/astral-sh/uv:python3.11-alpine / AMD64 Server
  • Pendulum version: 3.1.0

Issue

Running with New Relic
Fatal Python error: Segmentation fault

Current thread 0x0000ffffa3601d20 (most recent call first):
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1233 in create_module
  File "<frozen importlib._bootstrap>", line 573 in module_from_spec
  File "<frozen importlib._bootstrap>", line 676 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/usr/local/lib/python3.11/site-packages/pendulum/parser.py", line 21 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/usr/local/lib/python3.11/site-packages/pendulum/__init__.py", line 32 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/usr/local/lib/python3.11/site-packages/masoniteorm/models/Model.py", line 10 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/usr/local/lib/python3.11/site-packages/masoniteorm/models/__init__.py", line 1 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/usr/local/lib/python3.11/site-packages/masoniteorm/__init__.py", line 1 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1126 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1126 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/usr/local/lib/python3.11/site-packages/dots/utils/__init__.py", line 2 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1126 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/var/microservices/disco_service/app/services/disco_service.py", line 10 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/var/microservices/main.py", line 4 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 940 in exec_module
  File "<frozen importlib._bootstrap>", line 690 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "/usr/local/lib/python3.11/site-packages/nameko/cli/run.py", line 44 in import_service
  File "/usr/local/lib/python3.11/site-packages/nameko/cli/run.py", line 179 in main
  File "/usr/local/lib/python3.11/site-packages/nameko/cli/commands.py", line 113 in main
  File "/usr/local/lib/python3.11/site-packages/nameko/cli/main.py", line 143 in main
  File "/usr/local/bin/nameko", line 10 in <module>

Extension modules: yaml._yaml, greenlet._greenlet, __original_module__thread, __original_module_select, __original_module_time, charset_normalizer.md, requests.packages.charset_normalizer.md, requests.packages.chardet.md, gevent.libev.corecext, gevent._gevent_c_greenlet_primitives, gevent._gevent_c_hub_local, gevent._gevent_c_waiter, gevent._gevent_c_hub_primitives, gevent._gevent_c_ident, gevent._gevent_cgreenlet (total: 15)
Segmentation fault

Reverting to Pendulum < 3.0.0 fixes this issue. Not quite sure the origin of the issue is, will be very communicative in assisting you debug this.

terminalsin avatar May 10 '25 21:05 terminalsin

Dockerfile:

FROM ghcr.io/astral-sh/uv:python3.11-alpine
ARG LIB_REPO_GITHUB_USER
ARG LIB_REPO_GITHUB_TOKEN
ARG CONT_IMG_VER
ENV CONT_IMG_VER=${CONT_IMG_VER:-"1.0.0"}
ENV PYTHONDONTWRITEBYTECODE=True
ENV PYTHONFAULTHANDLER=1
ENV PENDULUM_EXTENSIONS=0
ENV UV_PROJECT_ENVIRONMENT=/usr/local

WORKDIR /var/microservices

# Install and clean up system dependencies in a single layer
RUN apk add tini mariadb-dev make
RUN apk add --no-cache --virtual .build-deps \
        make \
        gcc \
        g++ \
        git \
        gettext \
        libcap \
        libffi-dev \
        && git config --global url."https://${LIB_REPO_GITHUB_USER}:${LIB_REPO_GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/" \
        && setcap 'cap_net_bind_service=+eip' /usr/local/bin/python3.11 \
        && apk del .build-deps \
        && rm -rf /var/cache/apk/*

# Install dependencies using UV
ADD pyproject.toml ./
RUN apk add --no-cache --virtual .build-deps \
        git \
        && uv sync --no-dev \
        && apk del .build-deps \
        && rm -rf /var/cache/apk/*

# [fix] astral uv's image does not have xfs user
RUN addgroup -g 33 xfs && adduser -u 33 -G xfs -h /var/microservices -D xfs

ADD --chown=xfs:xfs src .
RUN chmod +x ./startup.sh

#Need of uid:gid 33:33 that is xfs in this image
USER xfs
ENTRYPOINT ["/sbin/tini", "--"]
CMD [ "./startup.sh" ]

terminalsin avatar May 10 '25 21:05 terminalsin

Could you please try to reproduce this on a publicly available project? Your container is based private project and we can't really work with it for debug purposes.

Secrus avatar May 10 '25 22:05 Secrus

Could you please try to reproduce this on a publicly available project? Your container is based private project and we can't really work with it for debug purposes.

Let me work on getting a debug sample project for ya. I'll lyk asap

terminalsin avatar May 10 '25 22:05 terminalsin

https://github.com/terminalsin/pendulum-sample-bug-898

terminalsin avatar May 10 '25 22:05 terminalsin

Could you please try to reproduce this on a publicly available project? Your container is based private project and we can't really work with it for debug purposes.

Hi just bumping this :)

terminalsin avatar May 26 '25 12:05 terminalsin

Hi. Unless you are willing to debug and fix this issue yourself, you will have to wait until one of the maintainers (there are only two of us) has some time to look into this issue.

Secrus avatar May 27 '25 00:05 Secrus