You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Gastón Kleiman (JIRA)" <ji...@apache.org> on 2017/09/01 21:24:00 UTC

[jira] [Assigned] (MESOS-7877) Audit test code for undefined behavior in accessing container elements

     [ https://issues.apache.org/jira/browse/MESOS-7877?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gastón Kleiman reassigned MESOS-7877:
-------------------------------------

    Assignee: Gastón Kleiman

> Audit test code for undefined behavior in accessing container elements
> ----------------------------------------------------------------------
>
>                 Key: MESOS-7877
>                 URL: https://issues.apache.org/jira/browse/MESOS-7877
>             Project: Mesos
>          Issue Type: Bug
>          Components: test
>            Reporter: Benjamin Bannier
>            Assignee: Gastón Kleiman
>              Labels: mesosphere, newbie, tech-debt, test
>
> We do not always make sure we never access elements from empty containers, e.g., we use patterns like the following
> {code}
> Future<vector<Offer>> offers;
> // Satisfy offers.
> EXPECT_FALSE(offers.empty());
> const auto& offer = (*offers)[0];
> {code}
> While the intention here is to diagnose an empty {{offers}}, the code still exhibits undefined behavior in the element access if {{offers}} was indeed empty (compilers might aggressively exploit undefined behavior to e.g., remove "impossible" code). Instead one should prevent accessing any elements of an empty container, e.g.,
> {code}
> ASSERT_FALSE(offers.empty()); // Prevent execution of rest of test body.
> {code}
> We should audit and fix existing test code for such incorrect checks and variations involving e.g., {{EXPECT_NE}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)