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

I have an idea what the bug can be #2

Open
ram-nat opened this issue Sep 24, 2015 · 0 comments
Open

I have an idea what the bug can be #2

ram-nat opened this issue Sep 24, 2015 · 0 comments

Comments

@ram-nat
Copy link

ram-nat commented Sep 24, 2015

Awesome work with your patch!

So, I ran into the same crash on my Ubuntu server and after digging through the code, I have an idea what the issue is - it is not due to re-entrancy issues, but a use after free bug in the code.

I think the code is incorrectly doing HASH_CLEAR after it has free'd the nodes (this is only a theory at this point, but one that I'm more than 50% confident in).

So here - https://github.com/crass/mhddfs/blob/c62547d50a574ed9e3b04a8533be1c350b08c2ea/src/main.c#L245-L251

Replace with:

    // free memory
    HASH_ITER(hh, items_ht, item, tmp) {
                HASH_DEL(items_ht, item);
        free(item->name);
        free(item->st);
        free(item);
    }

I haven't tried this out yet, but plan to do so when I get some time (I've downgraded to 1.38 in the meantime). The only advantage over your patch is that it won't have a new dependency and can continue to use ut_hash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant