word_cloud: Memory errors on Fedora 29

Description

I have strange memory errors on Fedora 29 when use wordcloud package. Error messages are:

munmap_chunk(): invalid pointer

or

malloc(): invalid next size (unsorted)

or

Segmentation fault

Steps/Code to Reproduce

I run this code (‘text’ argument is plain text in Russian, ‘filename’ - something like ‘output.png’):

Example:

# Bad example
from wordcloud import WordCloud

def make_wordcloud(text, filename):
    if len(text) == 0:
        print("Warning! No data for wordcloud")
        return
    wordcloud = WordCloud(background_color="#FFFFFF",
        width=800, height=400).generate(text)
    image = wordcloud.to_image()
    image.save(filename)

Something strange. When there are some unsused imports the code runs successfully.

# Good example
import matplotlib.pyplot as plt #unused import
from wordcloud import WordCloud
from gensim import corpora, models # and this one

def make_wordcloud(text, filename):
    if len(text) == 0:
        print("Warning! No data for wordcloud")
        return
    wordcloud = WordCloud(background_color="#FFFFFF",
        width=800, height=400).generate(text)
    image = wordcloud.to_image()
    image.save(filename)

Expected Results

I expect this code to run successfully.

Actual Results

I see “Segmentation fault” error. When run in GDB there is a backtrace like this one:

#0  0x00007ffff78e0e33 in free () from /lib64/libc.so.6
#1  0x00007fffd9962041 in raqm_layout () from /lib64/libraqm.so.0
#2  0x00007fffba5c373f in ?? () from /home/user/.local/lib/python3.7/site-packages/PIL/_imagingft.cpython-37m-x86_64-linux-gnu.so
#3  0x00007fffba5c3ab9 in ?? () from /home/user/.local/lib/python3.7/site-packages/PIL/_imagingft.cpython-37m-x86_64-linux-gnu.so
#4  0x00007ffff7d65444 in _PyMethodDef_RawFastCallKeywords () from /lib64/libpython3.7m.so.1.0
#5  0x00007ffff7d8040d in _PyMethodDescr_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#6  0x00007ffff7dcc0e0 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#7  0x00007ffff7d1daa8 in _PyEval_EvalCodeWithName () from /lib64/libpython3.7m.so.1.0
#8  0x00007ffff7d64cb1 in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#9  0x00007ffff7dc7481 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#10 0x00007ffff7d1daa8 in _PyEval_EvalCodeWithName () from /lib64/libpython3.7m.so.1.0
#11 0x00007ffff7d64cb1 in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#12 0x00007ffff7dc7481 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#13 0x00007ffff7d1daa8 in _PyEval_EvalCodeWithName () from /lib64/libpython3.7m.so.1.0
#14 0x00007ffff7d64cb1 in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#15 0x00007ffff7dc8512 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#16 0x00007ffff7d1daa8 in _PyEval_EvalCodeWithName () from /lib64/libpython3.7m.so.1.0
#17 0x00007ffff7d64cb1 in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#18 0x00007ffff7dc8512 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#19 0x00007ffff7d1daa8 in _PyEval_EvalCodeWithName () from /lib64/libpython3.7m.so.1.0
#20 0x00007ffff7d64cb1 in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#21 0x00007ffff7dc7481 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#22 0x00007ffff7d64b0a in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#23 0x00007ffff7dc7481 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#24 0x00007ffff7d64b0a in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#25 0x00007ffff7dc7481 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#26 0x00007ffff7d64b0a in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#27 0x00007ffff7dcbf79 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#28 0x00007ffff7d64b0a in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#29 0x00007ffff7dc7639 in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#30 0x00007ffff7d1daa8 in _PyEval_EvalCodeWithName () from /lib64/libpython3.7m.so.1.0
#31 0x00007ffff7d1e9d3 in PyEval_EvalCodeEx () from /lib64/libpython3.7m.so.1.0
#32 0x00007ffff7d1e9fb in PyEval_EvalCode () from /lib64/libpython3.7m.so.1.0
#33 0x00007ffff7e43732 in run_mod () from /lib64/libpython3.7m.so.1.0
#34 0x00007ffff7e43ac7 in PyRun_FileExFlags () from /lib64/libpython3.7m.so.1.0
#35 0x00007ffff7e464b8 in PyRun_SimpleFileExFlags () from /lib64/libpython3.7m.so.1.0
#36 0x00007ffff7e482a6 in pymain_main () from /lib64/libpython3.7m.so.1.0
#37 0x00007ffff7e484ec in _Py_UnixMain () from /lib64/libpython3.7m.so.1.0
#38 0x00007ffff787d413 in __libc_start_main () from /lib64/libc.so.6
#39 0x000055555555508e in _start ()

Versions

Linux-5.3.11-100.fc29.x86_64-x86_64-with-fedora-29-Twenty_Nine
Python 3.7.5 (default, Oct 17 2019, 12:21:00) 
[GCC 8.3.1 20190223 (Red Hat 8.3.1-2)]
NumPy 1.15.1
matplotlib 3.1.2
wordcoud 1.6.0

I have this error only in Fedora 29 (with different Python versions). When I run it in Linux Mint 19, Fedora 27 or Windows 10 everything seems well.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

Some update for this issue: this problem will be resolve for installing any version of Pillow by compiling from the source and passing a specific install option, by running this command. pip install -U --compile --install-option=-O1 Pillow --user

I had the same issue in fedora 30 and solved it by downgrading pillow version to 6.2.2. pip install --no-binary=Pillow Pillow==6.2.2 --force

FYI, @shirzady1934 's fix did it for me, but I did have to pass in --ignore-installed as I did this fix after things were already there.

I also didn’t use --user as I’m in a venv.

Full command:

 pip install --ignore-installed -U --compile --install-option=-O1 Pillow