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

hclose() descriptor while there is a bundle_wait() in it #215

Open
jcarrano opened this issue Mar 30, 2022 · 0 comments
Open

hclose() descriptor while there is a bundle_wait() in it #215

jcarrano opened this issue Mar 30, 2022 · 0 comments

Comments

@jcarrano
Copy link
Contributor

Question

Is it legal to issue a hclose() a bundle while at the same time there is a coroutine waiting (with bundle_wait()) on the same bundle?

Situation

From main() start a bundle and an additional "killer" coroutine that will eventually call hclose() on that bundle (it waits on a signalfd). Then main blocks with bundle_wait() on the bundle. When the bundle is closed by the killer main unblocks and everything seems to work, but Valgrind reports a use-after-free.

From the docs it is not clear if this usage is valid. If not, how would one handle this use case? Use channels?

Valgrind output

==80202== Invalid write of size 8
==80202==    at 0x487F501: dill_bundle_wait (cr.c:144)
                      .... etc ....
==80202==    by 0x114B59: run_daemon (main.c:177)
==80202==    by 0x114E19: main (main.c:253)
==80202==  Address 0x4c955a0 is 32 bytes inside a block of size 48 free'd
==80202==    at 0x484827F: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==80202==    by 0x487F41D: dill_bundle_close (cr.c:127)
==80202==    by 0x4880DD6: dill_hclose (handle.c:155)
==80202==    by 0x114954: signal_listener (main.c:105) <- This is  a couroutine
==80202==    by 0x114C94: run_daemon (main.c:166)
==80202==  Block was alloc'd at
==80202==    at 0x4845899: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==80202==    by 0x487F2DA: dill_bundle (cr.c:101)
==80202==    by 0x487F9F5: dill_prologue (cr.c:258)
                      .... etc ....
==80202==    by 0x114A62: run_daemon (main.c:141)
==80202==    by 0x114E19: main (main.c:253)
==80202== 
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