Skip to content

Conversation

@jonasohland
Copy link
Contributor

@jonasohland jonasohland commented Dec 21, 2025

Use posix_fallocate to resize the SHM files before mapping them.
ftruncate will succeed even if there is not enough space on the filesystem, and the program will crash when the memory is first used.

To reproduce:

$ sudo mount --mkdir -o size=1K -t tmpfs x /mnt/test
$ build/Linux-GCC-Debug/tools/mxl-gst/mxl-gst-testsrc -v lib/tests/data/v210_flow.json -d /mnt/test
Bus error (core dumped)

After the fix:

$ sudo mount --mkdir -o size=1K -t tmpfs x /mnt/test
$ build/Linux-GCC-Debug/tools/mxl-gst/mxl-gst-testsrc -v lib/tests/data/v210_flow.json -d /mnt/test
[2025-12-21 23:34:37.980] [console] [error] [flow.cpp:52] Failed to create flow : Shared memory segment does not meet the minimum size requirements.: Cannot allocate memory
[2025-12-21 23:34:38.231] [console] [error] [testsrc.cpp:919] Error while processing video pipeline: Failed to create flow with status code 1.

I have only observed this on arm64, but this could also be an issue on amd64.

@jonasohland jonasohland added this to the v1.0 milestone Dec 21, 2025
@jonasohland jonasohland self-assigned this Dec 21, 2025
@jonasohland jonasohland added the bug Something isn't working label Dec 21, 2025
Copy link
Contributor

@vt-tv vt-tv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding and fixing this very obscure issue!

Copy link
Contributor

@pedro-alves-ferreira pedro-alves-ferreira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jonasohland and others added 3 commits December 22, 2025 12:30
ftruncate will succeed even if there is not enough space on the
filesystem.

Co-authored-by: Jonas Ohland <jonas.ohland@gmail.com>
Signed-off-by: Jonas Ohland (Riedel) <jonas.ohland@riedel.net>
Signed-off-by: Jonas Ohland (Riedel) <jonas.ohland@riedel.net>
Co-authored-by: Jonas Ohland <jonas.ohland@gmail.com>
Signed-off-by: Jonas Ohland (Riedel) <jonas.ohland@riedel.net>
@vt-tv vt-tv force-pushed the bugfix/use-fallocate branch from c0fa597 to 8737401 Compare December 22, 2025 17:30
@vt-tv vt-tv merged commit 6c87947 into dmf-mxl:main Dec 22, 2025
9 checks passed
@jonasohland jonasohland deleted the bugfix/use-fallocate branch December 22, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants