From b6a3dbb83e8ee29a445cafab01b7adb7b90593df Mon Sep 17 00:00:00 2001 From: Matthew Fahrbach Date: Wed, 11 Dec 2024 16:21:35 -0800 Subject: [PATCH] [xla-auto-sharding] Fix potential dangling pointer (reference) bug. Note: - The scaled request object is allocated on the stack when `ScaleRequest` is called, but then it goes out of scope. - This change should be equally performant due to return value optimization. PiperOrigin-RevId: 705277876 --- xla/hlo/experimental/auto_sharding/auto_sharding_solver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xla/hlo/experimental/auto_sharding/auto_sharding_solver.cc b/xla/hlo/experimental/auto_sharding/auto_sharding_solver.cc index af9477a9a7187..354a00ba21aa8 100644 --- a/xla/hlo/experimental/auto_sharding/auto_sharding_solver.cc +++ b/xla/hlo/experimental/auto_sharding/auto_sharding_solver.cc @@ -539,7 +539,7 @@ void AddMemoryTerms( absl::StatusOr FormulateAndSolveMIPFromSolverRequest( const AutoShardingSolverRequest& unscaled_request) { const absl::Time start_time = absl::Now(); - const AutoShardingSolverRequest& request = ScaleRequest(unscaled_request); + const AutoShardingSolverRequest request = ScaleRequest(unscaled_request); const size_t num_edges = request.edges_size(); const int num_workers = 32; // SAT or SCIP