Repository navigation
lint-c passes on main again: tests initialize their textures where they live and check the archives they reopen, four analyzer false positives are marked, and the baseline drops 15 findings main no longer has - #1602
Closed
PucaVaz wants to merge 1 commit into
Conversation
…ey live and check the archives they reopen, four analyzer false positives are marked, and the baseline drops 15 findings main no longer has clang-tidy's ratchet (LLVM 23.1.4) has failed on main since b1d7c70: 8 file/check pairs above the baseline, and since d4239a6 12 below it. Fixed in the code: - t_dlss_mfx.m, t_upscaler_mfx.m (clang-analyzer-core.StackAddressEscape, from b1d7c70): g_tex_live now holds the address of the object mtl_tex_init is given, which mtl_tex_release reads to tell a finalized copy from the object itself. The tests' texture() initialized a local and returned a copy, so every entry pointed into its dead frame. It initializes the caller's object now. - t_depth16_clear.m (the same check, from b1d7c70): production_clears returned on a failed calloc after registering its two stack targets, without releasing them. The allocation comes first now. - t_pso_stall.m (clang-analyzer-nullability.NullablePassedToNonnull, reported since 88c7e03): reopen() added each archive to an NSMutableArray unchecked, and one that does not open would throw. It is checked (EXPECT) and left out. False positives, marked on their lines with // NOLINT(<check>) and the reason: - nvn_mtl.m pkg_share_put (clang-analyzer-osx.cocoa.RetainCount, b1d7c70): g_pkg_share owns the NvPkgRef through hm_put_id's CFBridgingRetain, as for the other hm_put_id tables already marked. - nvn_mtl.m mtl_pool_addressed (clang-analyzer-security.ArrayBound, memory preceding the heap area, b1d7c70): the analyzer takes addr_first's index and g_naddr for any int; the index is 0 to g_naddr, which is never negative. - nvn_mtl.m pool_seen_scan (clang-analyzer-core.BitwiseShift, b1d7c70): b is __builtin_ctz of a non-zero word, 0 to 31; the path assumes it below -32. - t_feedback.m (bugprone-signed-char-misuse, 0cefa86): fx's -1 (a constant not read from the tile) must reach bf_fn as -1; the cast the check suggests would make it 255. nvn_mtl.m's own copy in warm_task is already a baseline entry. Baseline: lint_c.py tidy --update drops what main no longer has, 240 to 225 findings: 14 clang-analyzer-osx.cocoa.RetainCount entries of 11 tests, gone since d4239a6, and one of t_image_alias.m's two nullability entries, gone since b1d7c70.
Contributor
Author
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.
main's lint-c (clang-tidy ratchet, LLVM 23.1.4) has failed since b1d7c70, and every pull request's merge with main inherits it. The last completed run on main, 42264410010 on 6bbdbbe (main's tip b2d46b8 changes no linted file), had 8 file/check pairs above the baseline and 12 below it. This change takes both to 0: 225 findings against a baseline of 225.
Above the baseline: fixed
dm/gfx/tests/t_dlss_mfx.m,t_upscaler_mfx.mclang-analyzer-core.StackAddressEscapeg_tex_liveholds the address of the objectmtl_tex_initis given, andmtl_tex_releasereads it to tell a finalized copy from the object. The tests'texture()initialized a local and returned a copy, so each entry pointed into its dead frame.texture()now initializes the caller's object.dm/gfx/tests/t_depth16_clear.mclang-analyzer-core.StackAddressEscapeproduction_clearsreturned on a failedcallocafter registering its two stack targets, without releasing them. The allocation comes first now.dm/gfx/tests/t_pso_stall.mclang-analyzer-nullability.NullablePassedToNonnull(2, baseline 1)reopen()added each archive to anNSMutableArrayunchecked; one that does not open would throw. Each is checked withEXPECTand left out when nil. The older finding (line 107) stays in the baseline.Above the baseline: false positives, marked with
// NOLINT(<check>)and the reasondm/gfx/nvn/nvn_mtl.mpkg_share_putclang-analyzer-osx.cocoa.RetainCount("leak of 'r'")g_pkg_shareowns theNvPkgRefthroughhm_put_id'sCFBridgingRetainuntilhm_del_idor a replacing put releases it, as for thehm_put_idtables already marked (g_pbase_pending).dm/gfx/nvn/nvn_mtl.mmtl_pool_addressedclang-analyzer-security.ArrayBound("memory preceding the heap area")i == g_naddr,i <= 0andg_naddr == g_addr_cap != 0, so a negative index.icomes fromaddr_first, which returns 0 tog_naddr, andg_naddrchanges only on that line, from 0 up by one insert or down by a merge that keeps at least one range.dm/gfx/nvn/nvn_mtl.mpool_seen_scanclang-analyzer-core.BitwiseShift("right operand is negative")i = 1) and assumesid_ = 32 + b <= 0, sob <= -32.bis__builtin_ctzof a non-zero word, 0 to 31.dm/gfx/tests/t_feedback.mbugprone-signed-char-misusefxholds attachment indices and -1 for a constant not read from the tile (fb_tile_plan);bf_fnpasses them as int function constants, so the -1 has to sign-extend. The cast the check suggests would make it 255. nvn_mtl.m's own copy inwarm_taskis already a baseline entry.The other nvn_mtl.m findings in the failing run's annotations (
'ps'RetainCount,S.streamandg_mrbArrayBound) are the baseline's existing entries, present in the last green run (95f9a6a).Below the baseline:
lint_c.py tidy --updateThe baseline goes from 240 to 225 findings:
clang-analyzer-osx.cocoa.RetainCountentries of t_alpha, t_defer_chain, t_geometry (2), t_geometry_feedback, t_present_snap, t_primitive_restart, t_pso_pending (2), t_rt_range, t_unwritten_store, t_view_swizzle (2) and t_zskip, gone since d4239a6 (present at bd9f422, absent at d4239a6). t_feedback.m's two RetainCount findings, above a baseline of 0 in earlier failing runs, went with them.NullablePassedToNonnullentries, gone since b1d7c70 (two at b1d7c70~1, one at b1d7c70).No open pull request fixes these: #1389 and #1275 list the same pairs as coming from main and leave them.
Testing
With LLVM 23.1.4 (the release and sha256 lint-c.yml pins) and Xcode 27.2 (
DEVELOPER_DIR, as CI), on an M4 Mac:python3 dm/tools/lint_c.py compdb && python3 dm/tools/lint_c.py tidy -j 8 --against origin/main: 225 findings, baseline 225, 0 pairs above it, 0 below it, the baseline not grown over origin/main; exit 0. Against CI's report for 6bbdbbe the only difference is the 8 findings above. On unmodified main, the same clang-tidy with Xcode 27.0's SDK reproduced CI's report finding for finding, plus 8 parse errors in front_mac.m from that older SDK.python3 -m unittest dm/tools/tests/test_lint_c.py: 19 tests pass.make -C dm/gfx/tests GAME=0400486024DEC000withcheck_t_depth16_clear(1042 depths, both production clears match the fragment),check_t_dlss_mfx(7 checks, 0 failed, encoding thread off and on),check_t_upscaler_mfx(91, 91 and 12 checks, 0 failed),check_t_feedback(193 checks, 0 failed) andcheck_t_pso_stall(44 checks, 0 failed): all pass.make -C dm/host GAME=0400486024DEC000: the Mac host builds.