Skip to content

With millions of files, process_lint() causes shell to segfault #236

@Nemykal

Description

@Nemykal

Hi,

I run rmlint on Arch and noticed it recently got upgraded to 2.6.0.

When I run rmlint -c sh:hardlink -g /storage/backups on a directory that has millions of files underneath it completes without error... but when I run the produced rmlint.sh script, it segfaults since the new version.

e.g. rmlint.sh[4460]: segfault at 7ffc011d4ff0 ip 00007f25cf2c942c sp 00007ffc011d4fe0 error 6 in libc-2.25.so[7f25cf24e000+19c000]

I got the same crash with the dry-run setting. I also tried using busybox sh and zsh - both got the same segfault.

This is a pretty weird one because when I looked into the coredump, bash dies during a call to malloc():

                #0  0x00007fcf842c942c _int_malloc (libc.so.6)
                #1  0x00007fcf842cafb8 malloc (libc.so.6)
                #2  0x000000000047224e xmalloc (bash)
                #3  0x000000000043ca91 copy_command (bash)
                #4  0x000000000043cbe8 copy_command (bash)
                #5  0x000000000043cbe8 copy_command (bash)
                #6  0x000000000043cbe8 copy_command (bash)
                #7  0x000000000043cbe8 copy_command (bash)
                #8  0x000000000043cbe8 copy_command (bash)
... (same line repeated until #63)

I tried this on an Alpine Linux system (i.e. not using glibc's malloc) and got the same crash, so I think it is probably some kind of posix limitation on stuff in a single function. To be fair, there's a lot:

$ wc -l rmlint.sh
14287545 rmlint.sh

It's definitely a regression because I tried reverting back to rmlint 2.4.6 and confirmed the issue doesn't happen. Moving the commands into a function appears to be the cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions