Skip to content

Memory Access Violation on SANE's test backend #2

Description

@goncalomb

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions