libvips / pyvips

python binding for libvips using cffi
MIT License
649 stars 50 forks source link

Segmentation fault (core dumped) #418

Closed knoppmyth closed 1 year ago

knoppmyth commented 1 year ago

I've searched the issues and not seeing an exact match to what I'm see.

import pyvips

tiles_across = 240
tiles_down = 149

pyvips.cache_set_max(0)
pyvips.leak_set(True)

tiles = [pyvips.Image.new_from_file(f"{x}_{y}.png", access="sequential")
         for y in range(tiles_down) for x in range(tiles_across)] 
image = pyvips.Image.arrayjoin(tiles, across=tiles_across)
image.write_to_file("test.1.tiff", pyramid=True, compression="jpeg", tile=True)

I'm running the above with

VIPS_CONCURRENCY=1 python write_wsi.py

It runs for a while but

Segmentation fault (core dumped)

after a little bit...

I'm running on a system with 32GB of RAM. I monitored memory usage and I'm not running out of memory. I'm running on Arch Linux in a venv. pyvips version is 2.2.1 libvips version is 8.14.2

Please let me know what other information I can provide.

jcupitt commented 1 year ago

Hi @knoppmyth, I would guess this is related to musl, the arch C runtime. Perhaps you are running out of stack? musl defaults to an extremely small C stack which can cause issues. Though I think they've raised this a bit now.

jcupitt commented 1 year ago

libvips tries to raise the minimum stack size as it starts up, but it can't do this if libvips init happens after the first thread has been created. Importing libvips right at the start might help, or recoding your program in C could help.

knoppmyth commented 1 year ago

Hello @jcupitt thanks for the information. I did have success running this the later part of last year. Of course Arch has been updated a lot since then... Unfortunately, I'm not proficient in C.

knoppmyth commented 1 year ago

I've made a docker image to do my work.