Segmentation fault (core dumped) from pyvips
See original GitHub issueI’m trying to resize a large image to a smaller width with a limited memory available 256MB (due to AWS lambda configuration). I used the code like this:
import pyvips
image = pyvips.Image.new_from_file(src_file, access='sequential')
image = image.resize(0.8/1.0)
image.write_to_file(dst_file)
In my local machine I’m testing it by putting a limit on Python VM using code like:
resource.setrlimit(resource.RLIMIT_AS, (maxsize, hard))
when I set the maxsize
to 256MB, I get Segmentation fault (core dumped)
error. I suppose this is coming from the vips C library. So, I have two questions:
- Why the memory issue in vips library (assuming there is one) is not raised as MemoryError for python to handle gracefully?
- How can I use pyvips to resize a very big image with relatively small memory environment such as AWS lambda? [I can sacrifice CPU performance but I need the memory performance]
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
How can I avoid a "Segmentation Fault (core dumped)" error ...
JP2 > ~500 MB, Python3 throws the following error when attempting to load an image: "Segmentation Fault (core dumped)".
Read more >I get "Segmentation fault(core dumped)" : r/cs50 - Reddit
A segmentation fault is, in essence, when the program is trying to access some memory that it isn't meant to. In this case,...
Read more >Introduction — pyvips 2.2.1 documentation
You can also write formatted images to memory, or dump image data to a C-style ... As well as the core properties, you...
Read more >libvips - Bountysource
Thread 4 "environment" received signal SIGSEGV, Segmentation fault. ... 'VipsSequential' qemu: uncaught target signal 11 (Segmentation fault) - core dumped.
Read more >Segmentation fault (core dumped) - Python Forum
Any idea what is wrong with this code here and gives me Segmentation fault (core dumped)??? I got the code from here:
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 FreeTop 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
Top GitHub Comments
Sorry, I never answered your first question.
Out of memory errors are generally impossible to handle gracefully. Suppose memory is full and a fault is raised. What is going to handle the error? If no more memory can be used, no fault handler can execute. Like almost all software, libvips treats memory as an infinite resource and relies on the environment to manage it.
libvips does check large single allocations (for example, loading a 10gb image into memory), but does not check small ones, the reasoning being that, if a small allocation fails, the process is as good as dead.
I tried this program:
leak_set
makes libvips run a little slower, but it will check for leaks and report high-water memory usage. With a 10k x 10k pixel RGB image I see:If I change the program like this:
I see:
That’s running with
ulimit -m 256000
, which might be equivalent to your settings. I couldn’t get it to crash.