Skip to content

Segfault with black 22.1.0 #2845

Closed
Closed
@evilrhinohater

Description

@evilrhinohater

Describe 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: crashBlack is crashingC: packagingInstallation and packaging of BlackS: blockedA decision or another issue needs to be made/resolved before this can be worked on (more).T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions