fix(globals): reject -r 0 to match must-be-positive contract (#71)#86
Merged
Conversation
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.
Summary
Globals::parse_args(src/globals.cpp) validated the-r/--max-ramvalue withif (this->max_ram < 0), but the error message reads"Max RAM must be positive". Message and logic disagreed:-r 0was silently accepted despite the message claiming the value must be positive.How
max_ramis used downstreamI checked whether
0is a meaningful sentinel (e.g. "unlimited") before choosing a fix. It is not:src/globals.cpp:439—ram_steps.push_back(this->max_ram / threads); withmax_ram == 0every RAM step is0.src/dist.cpp:790—while (total_ram < g.max_ram && thread_step >= 0);total_ramstarts at0, so0 < 0is false and the "not enough work for all threads" branch schedules zero threads, silently dropping superclusters.src/cluster.cpp:607—if (mem_gb > g.max_ram); withmax_ram == 0every supercluster "exceeds" RAM and triggers the warning path.There is no "0 means unlimited" semantics anywhere;
0simply breaks scheduling.Fix
Changed the check to
if (this->max_ram <= 0)so the validation matches the "must be positive" contract stated in the message. This is the minimal change and the option consistent with actual usage (rather than softening the message, since0is not a valid value).Compile check
cd src && g++ -c -g -O1 -Wall -Wextra -std=c++17 globals.cpp -o /tmp/probe_71.o— clean, no warnings.Fixes #71
Sub-issue of #45; documented in docs/D2_vcfdist-v3-unit-tests.md §6 defect #13.