Skip to content

Commit 0714a39

Browse files
saladqcopybara-github
authored andcommitted
Cleanup FUZZTEST_STACK_LIMIT env var in favor of --stack_limit_kb flag.
PiperOrigin-RevId: 766227743
1 parent 263ba82 commit 0714a39

File tree

4 files changed

+2
-50
lines changed

4 files changed

+2
-50
lines changed

e2e_tests/functional_test.cc

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,32 +1102,6 @@ TEST_F(FuzzingModeCommandLineInterfaceTest, ConfiguresStackLimitByFlag) {
11021102
ExpectTargetAbort(status, std_err);
11031103
}
11041104

1105-
TEST_F(FuzzingModeCommandLineInterfaceTest,
1106-
ConfiguresStackLimitByEnvVarWithWarning) {
1107-
auto [status, std_out, std_err] =
1108-
RunWith({{"fuzz", "MySuite.DataDependentStackOverflow"}},
1109-
{{"FUZZTEST_STACK_LIMIT", "512000"}});
1110-
EXPECT_THAT(std_err, HasSubstr("argument 0: "));
1111-
EXPECT_THAT(std_err,
1112-
HasSubstr(absl::StrCat(
1113-
"Stack limit is set by FUZZTEST_STACK_LIMIT env var - this "
1114-
"is going to be deprecated soon. Consider switching to ",
1115-
CreateFuzzTestFlag("stack_limit_kb", ""), " flag.")));
1116-
ExpectStackLimitExceededMessage(std_err, 512000);
1117-
ExpectTargetAbort(status, std_err);
1118-
}
1119-
1120-
TEST_F(FuzzingModeCommandLineInterfaceTest,
1121-
ConfiguresStackLimitByEnvVarAndOverridesFlag) {
1122-
auto [status, std_out, std_err] =
1123-
RunWith({{"fuzz", "MySuite.DataDependentStackOverflow"},
1124-
{"stack_limit_kb", "1000"}},
1125-
{{"FUZZTEST_STACK_LIMIT", "512000"}});
1126-
EXPECT_THAT(std_err, HasSubstr("argument 0: "));
1127-
ExpectStackLimitExceededMessage(std_err, 512000);
1128-
ExpectTargetAbort(status, std_err);
1129-
}
1130-
11311105
TEST_F(FuzzingModeCommandLineInterfaceTest,
11321106
DoesNotPrintWarningForDisabledLimitFlagsByDefault) {
11331107
auto [status, std_out, std_err] = RunWith(

fuzztest/internal/centipede_adaptor.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,7 @@ class CentipedeAdaptorRunnerCallbacks
559559
namespace {
560560

561561
void PopulateTestLimitsToCentipedeRunner(const Configuration& configuration) {
562-
if (const size_t stack_limit =
563-
GetStackLimitFromEnvOrConfiguration(configuration);
564-
stack_limit > 0) {
562+
if (const size_t stack_limit = configuration.stack_limit; stack_limit > 0) {
565563
absl::FPrintF(GetStderr(), "[.] Stack limit set to: %zu\n", stack_limit);
566564
CentipedeSetStackLimit(/*stack_limit_kb=*/stack_limit >> 10);
567565
}

fuzztest/internal/runtime.cc

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,30 +1010,12 @@ void FuzzTestFuzzerImpl::PopulateFromSeeds(
10101010
});
10111011
}
10121012

1013-
size_t GetStackLimitFromEnvOrConfiguration(const Configuration& configuration) {
1014-
size_t env_stack_limit;
1015-
if (const char* env = getenv("FUZZTEST_STACK_LIMIT");
1016-
(env != nullptr && absl::SimpleAtoi(env, &env_stack_limit))) {
1017-
absl::FPrintF(
1018-
GetStderr(),
1019-
"[!] Stack limit is set by FUZZTEST_STACK_LIMIT env var - this is "
1020-
"going to be deprecated soon. Consider switching to "
1021-
"--" FUZZTEST_FLAG_PREFIX "stack_limit_kb flag.\n");
1022-
return env_stack_limit;
1023-
}
1024-
return configuration.stack_limit;
1025-
}
1026-
10271013
void PopulateLimits(const Configuration& configuration,
10281014
ExecutionCoverage* execution_coverage) {
10291015
// centipede_adaptor would populate the limits to Centipede.
10301016
#ifndef FUZZTEST_USE_CENTIPEDE
1031-
// TODO(b/273276918): For now, let existing FUZZTEST_STACK_LIMIT overwrite the
1032-
// stack limit. So that the existing targets that set the env var could still
1033-
// work.
10341017
if (execution_coverage)
1035-
execution_coverage->SetStackLimit(
1036-
GetStackLimitFromEnvOrConfiguration(configuration));
1018+
execution_coverage->SetStackLimit(configuration.stack_limit);
10371019
#endif
10381020
}
10391021

fuzztest/internal/runtime.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ class FuzzTestFuzzerImpl : public FuzzTestFuzzer {
431431
friend class CentipedeAdaptorEngineCallbacks;
432432
};
433433

434-
size_t GetStackLimitFromEnvOrConfiguration(const Configuration& configuration);
435-
436434
// A reproduction command template will include these placeholders. These
437435
// placeholders then will be replaced by the proper test filter when creating
438436
// the final reproduction command from the template.

0 commit comments

Comments
 (0)