Replace removed crypto:random_bytes/1 with crypto:strong_rand_bytes/1 - #4241
Open
tas50 wants to merge 1 commit into
Open
Replace removed crypto:random_bytes/1 with crypto:strong_rand_bytes/1#4241tas50 wants to merge 1 commit into
tas50 wants to merge 1 commit into
Conversation
crypto:random_bytes/1 was removed from OTP years ago and does not exist
in any currently supported release. Calling test_data/1 raises undef on
OTP 26 today, and equally on 27 and 28:
{'EXIT', {undef, [{crypto,random_bytes,[4],[]}, ...]}}
Remote calls are not resolved at compile time, so nothing flags this
during the build, and test_data/1 is currently unreferenced within the
suite, which is why it has gone unnoticed. It survives compilation only
because the suite sets -compile(export_all).
crypto:strong_rand_bytes/1 is the supported replacement and is already
what bookshelf_bench uses to build test payloads of a given size, so
this keeps the helper consistent with the rest of the app.
Found while auditing the Erlang sources for calls to OTP functions that
no longer exist, by checking every module:function pair in the tree
against the exports of a real OTP 28 runtime. This was the only genuine
hit.
Signed-off-by: Tim Smith <tim@mondoo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bkswt_api_SUITE:test_data/1callscrypto:random_bytes/1, which was removed from OTP years ago and does not exist in any currently supported release. Calling it raisesundef— on the pinned OTP 26 today, and equally on 27 and 28:Two things have kept this hidden:
test_data/1is currently unreferenced within the suite (only its siblingtest_data_text/1is called), and it survives the "function unused" check only because the suite sets-compile(export_all).It is therefore a latent landmine rather than a live failure — but it is exactly the kind of thing worth clearing out before an OTP upgrade, since anyone wiring
test_data/1into a case would hit anundefthat looks like an OTP regression.Fix
crypto:strong_rand_bytes/1is the supported replacement, and is already whatbookshelf_benchuses to build test payloads of a given size (bookshelf_bench.erl:109and:149), so this keeps the helper consistent with the rest of the app.How this was found
While auditing the Erlang sources ahead of an OTP upgrade, I checked every
module:functionpair in the tree against the exports of a real OTP 28 runtime. Nine pairs came back unresolved; eight were remote type references in specs and records (calendar:datetime(),dict:dict(),file:io_device(),file:posix(),re:mp(),proplists:proplist(),gb_trees:tree(),calendar:datetime1970()), which are all legitimate.crypto:random_byteswas the only genuine hit in the entire tree.