python-pillow / python-pillow/Sane

Segfault if `progress` function passed into `SaneDev.snap()` has one argument

Open
#81 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
61
Forks
22
PR merge metrics
No merged PRs in 30d

Description

I couldn't find anything in the docs about how to use the progress callback function available in SaneDev.snap(). My first try was to pass in a function with only one argument, and this caused a segmentation fault in the python interpreter. (For anyone looking, you need to pass in a function that accepts two arguments. The first will be the number of lines scanned so far, and the second will be the total number of lines).

I'm not super familiar with CPython but it looks like passing two arguments into a python callable that only accepts one causes a segfault. I couldn't find a way in the docs to check the number of arguments in CPython (that must exist right?) so I don't know how to fix it in _sane.c. However one simple fix within sane.py would be to check the type of the progress object passed in to snap(), and wrap it in a function that accepts two arguments.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sane.py and _sane.c, then reproduce SaneDev.snap() with a progress callback accepting one argument and compare it with the documented two-argument form. Trace how the callback is invoked and ensure the one-argument case no longer segfaults; update the documentation if the callback requirements remain unclear.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.