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

Crash using binary_memory on a dead process #95

Closed
digitalcora opened this issue Aug 2, 2021 · 3 comments · Fixed by #97 or #115
Closed

Crash using binary_memory on a dead process #95

digitalcora opened this issue Aug 2, 2021 · 3 comments · Fixed by #97 or #115

Comments

@digitalcora
Copy link

digitalcora commented Aug 2, 2021

erlang:process_info/2 can return undefined — the docs don't explain why, but it's in the typespec and definitely happens when the queried process is dead. If using recon:info/2 with the binary_memory attribute, Recon doesn't handle this return value and crashes in an internal call to proc_fake (see here).

Additionally, the typespec for recon:info/2 doesn't include undefined as a possible return value, even though it can return this (e.g. if used on a dead process).

Example in Elixir, because I'm not very good at Erlang syntax, but hopefully it makes sense:

pid = spawn(fn -> true end) # spawn a process that immediately dies
Process.sleep(100) # give it a moment to finish
:recon.info(pid, [:binary_memory])
** (FunctionClauseError) no function clause matching in :recon.proc_fake/2

    The following arguments were given to :recon.proc_fake/2:

        # 1
        [:binary_memory]

        # 2
        :undefined

    (recon 2.5.2) src/recon.erl:247: :recon.proc_fake/2
@digitalcora
Copy link
Author

We recently tried to remove our workaround for this issue, but it appears to still exist in the current version 2.5.6 — the repro I posted above results in exactly the same internal crash (source line, which was not changed in #97).

@ferd
Copy link
Owner

ferd commented Nov 16, 2024

See if #115 works; I'm sorry I couldn't get to this better, it was a straightforward fix and the test should be robust enough.

@ferd ferd closed this as completed in #115 Nov 21, 2024
@ferd ferd closed this as completed in e3e7289 Nov 21, 2024
@digitalcora
Copy link
Author

Thanks @ferd, from our testing so far this issue seems fixed, as long as we handle the possible undefined.

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