Segfault with black 22.1.0
See original GitHub issueDescribe the bug
When running black with a self-built Python 3.10 I get a segfault.
To Reproduce
Can be reproduced in Docker:
#Dockerfile
FROM ubuntu:20.04
RUN sed -i '/deb-src/s/^# //' /etc/apt/sources.list
RUN apt-get update
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=UTC
RUN apt-get build-dep -y python3
# https://devguide.python.org/setup/#install-dependencies
RUN apt-get install -y build-essential gdb lcov pkg-config \
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
lzma lzma-dev tk-dev uuid-dev zlib1g-dev
RUN apt-get -y install curl
RUN curl -o Python-3.10.2.tar.xz https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
RUN tar xf Python-3.10.2.tar.xz
RUN cd Python-3.10.2 \
&& ./configure --with-pydebug --with-ensurepip \
&& make \
&& make altinstall
RUN adduser myuser
RUN mkdir -p /var/blacktest
RUN chown myuser:myuser /var/blacktest
ENV PATH /usr/local/bin:${PATH}
USER myuser
WORKDIR /var/blacktest
COPY Pipfile Pipfile
RUN pip3.10 install pipenv
RUN python3.10 -m pipenv install --dev
Pipfile
:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
black = "*"
[requires]
python_version = "3.10"
Then running black leads to a segfault error
$ docker build -t blacktest .
$ docker run --rm -it blacktest
myuser@c19751e02d87: python3.10 -m pipenv shell
(blacktest) myuser@c19751e02d87:/var/blacktest$ black
Objects/typeobject.c:5970: type_ready_checks: Assertion "type->tp_call != ((void *)0)" failed
Enable tracemalloc to get the memory block allocation traceback
object address : 0x559372c83ca0
object refcount : 1
object type : 0x55937285cea0
object type name: type
object repr : Segmentation fault (core dumped)
Expected behavior
Black should not lead to a segfault.
Environment
- Black’s version: 22.1.0
- OS and Python version: Ubuntu 20.04, Python 3.10 (built from source, see above)
** Further remarks **
Curiously, I could run the tests as instructed without errors.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
What causes a Python segmentation fault? - Stack Overflow
This happens when a python extension (written in C) tries to access a memory beyond reach. You can trace it in following ways....
Read more >Mesa 22.1.0 Release Notes / 2022-05-18
Mesa 22.1.0 is a new development release. People who are concerned with stability and reliability should stick with a previous release or ...
Read more >Nouveau NV4A glxgears segmentation fault (#6639) · Issues
I am running glxgears on GeForce6200 (NV4A) and I am getting segmentation fault after a black window is displayed.
Read more >Bug#1007992: libigdgmm12: new version causes segfaults
Mar 20 04:30:17 heisenberg kernel: mpv/vo[292810]: segfault at 300000200 ip 00007f93a01e49ae sp 00007f93ab2514b0 error 4 in ...
Read more >Issue 4313: IDLE segfault at exit - Python tracker
10 0 -foreground 1 black 2 -selectforeground 3 black 4 -selectbackground 5 black 6 -background 7 black 8 -insertbackground 9 Traceback (most ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/python/mypy/pull/13152 fixes this, but it hasn’t made its way into a mypy release yet. The next release is being tracked in https://github.com/python/mypy/issues/13385 but it seems to be behind schedule (as usual for mypy). Once mypy cuts a new release I’ll upgrade our mypy[c] cibuildwheel requirement, resolving this.
I recommend using
--no-binary black
instead of blocklisting all wheels from deps to minimize build time issues even from Pure Python packages.