Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Access Violation on SANE's test backend #2

Open
goncalomb opened this issue Apr 28, 2023 · 0 comments
Open

Memory Access Violation on SANE's test backend #2

goncalomb opened this issue Apr 28, 2023 · 0 comments
Labels
good first issue Good for newcomers

Comments

@goncalomb
Copy link
Owner

During the sane-wasm build we are suppose to set number_of_devices to 0 (test backend). But I've discovered an issue with that option, see build.sh comment:

sane-wasm/build.sh

Lines 236 to 251 in 3100bc9

# Set test backend's number of devices to 0.
# XXX: Oops what? There is some kind of invalid memory access on the backend
# file deps/backends/backend/test.c, setting number_of_devices to 0 causes
# some weird behavior and it's as if 1 device was selected.
# I've looked briefly into this, but was unable to find the cause,
# it's somehow related to how the option is read with:
# read_option (line, "number_of_devices", ...
# and then used on a for loop:
# for (num = 0; num < init_number_of_devices; num++)
# that loop should never run with init_number_of_devices = 0.
# I've tested this config on my linux distribution version of SANE and
# it triggers a Segmentation Fault so there is definitely a problem there.
# XXX: Setting it to -999 for now, fix this, and revert this to 0.
# The fix should probably be pushed upstream to SANE itself:
# https://gitlab.com/sane-project/backends/-/issues
sed -i "s/^number_of_devices .*/number_of_devices -999/g" "$PREFIX/etc/sane.d/test.conf"

The issue is most likely on the file backends/backend/test.c.

The backends patch should be updated to include the fix: https://github.com/goncalomb/sane-wasm/tree/master/deps. And bonus points for fixing it upstream: https://gitlab.com/sane-project/backends/-/issues.

@goncalomb goncalomb added the good first issue Good for newcomers label Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant