-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
process_info/2 doesn't report some large appended binaries. #6573
Comments
When writable binaries were introduced in erlang#5195, they weren't added to the output of `process_info(Pid, binary)`. It led to interesting effects of binaries suddenly disappearing after running implicit GC caused by BIF calls, including `process_info` itself. Effectively, running `process_info(self(), binary)` twice in a row resulted in different lists, because first call triggers GC clearing out original binary from the off-heap list: start() -> OffHeapBin = crypto:strong_rand_bytes(1024 * 1024), Bin = <<OffHeapBin/binary, "a">>, Before = erlang:process_info(self(), [binary]), After = erlang:process_info(self(), [binary]), Before =/= After andalso erlang:display({wtf, Before, After}), Bin. Fixes erlang#6573
I did some investigating / debugging in the emulator today and became a bit wiser. Would it be correct to collect the wrt_bins in the process_info as well? As to why it looks like they are reported under some circumstances, I found this comment in
So it might be the case that GC decides to move the no-longer-referenced ProcBin's from the |
Yes, "inactive" writable binaries are moved from wrt_bins to off_heap by the GC in sweep_off_heap() in erl_gc.c. The separate wrt_bins list was introduced as an optimization in 25.0, so this bug should not exist before that. |
I can confirm that the bug isn't present in 24. |
Fixed by #6574. |
Describe the bug
process_info/2 doesn't report some large appended binaries. This behavior seems to be dependent on the size of the first binary in the append.
There is also a difference sometimes between calling process_info for self process vs another process. Where calling process_info for self usually has more chance of getting results.
To Reproduce
Compile this module
then run
On my machine I get these results (consistently)
This line triggers the issue:
Bin = <<RandomBytes/binary, "a">>,
Replacing it with just
Bin = RandomBytes/binary,
does work as expected.
Expected behavior
To see at least the currently referenced large binaries reported.
Affected versions
Erlang/OTP 25 [erts-13.1.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns] [dtrace]
I have seen this issue on older versions too.
Additional context
Running on an Intel Mac with macOS 12.6.
The text was updated successfully, but these errors were encountered: