You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2020/03/13 18:11:37 UTC

[mesos] branch master updated: Fixed undefined behavior in ActionObject::reserve.

This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 89d773c  Fixed undefined behavior in ActionObject::reserve.
89d773c is described below

commit 89d773ca5c8f351f00a7eca2705e47c071d1a9c7
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Thu Mar 12 16:15:05 2020 -0400

    Fixed undefined behavior in ActionObject::reserve.
    
    Found by Andrei Sekretenko using -fsanitize=address, the following
    expression has an intermediate temporary!
    
      const RepeatedPtrField<Resource::ReservationInfo>&
        ancestorReservations =
        RepeatedPtrField<Resource>(ancestor).begin()->reservations();
    
    Therefore, the intermediate temporary will not have its lifetime
    extended and this is undefined behavior which leads to a crash
    in the windows CI.
    
    Review: https://reviews.apache.org/r/72233
---
 src/master/authorization.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/master/authorization.cpp b/src/master/authorization.cpp
index 6dfa59a..3ba1478 100644
--- a/src/master/authorization.cpp
+++ b/src/master/authorization.cpp
@@ -223,9 +223,9 @@ vector<ActionObject> ActionObject::reserve(
   }
 
   // We request RESERVE_RESOURCES to bring `ancestor` to `target`.
-  const RepeatedPtrField<Resource::ReservationInfo>& targetReservations =
+  const RepeatedPtrField<Resource::ReservationInfo> targetReservations =
     reserve.resources(0).reservations();
-  const RepeatedPtrField<Resource::ReservationInfo>& ancestorReservations =
+  const RepeatedPtrField<Resource::ReservationInfo> ancestorReservations =
     RepeatedPtrField<Resource>(ancestor).begin()->reservations();
 
   // Skip reservations common among `source` and `resources`.