Skip to content

Crash with an error: munmap_chunk(): invalid pointer #4225

@catcombo

Description

@catcombo

What did you do?

I was faced a problem when using arcade library. It uses Pillow under the hood to work with images. When I tried to draw game score text, I got random crash. I localized the problem and found out that crash is related to the way the Pillow works with font and frees up a resources.

What actually happened?

Crash with an error:

munmap_chunk(): invalid pointer
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

What are your OS, Python and Pillow versions?

  • OS: Fedora 30
  • Python: 3.7.5
  • Pillow: 6.2.1

Code example

Crashing code example (munmap_chunk(): invalid pointer):

import PIL.Image
import PIL.ImageDraw
import PIL.ImageFont


while True:
    image = PIL.Image.new("RGBA", (10, 10))
    draw = PIL.ImageDraw.Draw(image)
    font = PIL.ImageFont.truetype("Arial.ttf", 12)
    print(draw.multiline_textsize("Sample", font=font))

Works without any problem:

import PIL.Image
import PIL.ImageDraw
import PIL.ImageFont


font = PIL.ImageFont.truetype("Arial.ttf", 12)

while True:
    image = PIL.Image.new("RGBA", (10, 10))
    draw = PIL.ImageDraw.Draw(image)
    
    print(draw.multiline_textsize("Sample", font=font))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions