Bug 255915 - net-im/licq: Fix null pointer accesses in googletest framework
Summary: net-im/licq: Fix null pointer accesses in googletest framework
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks: 255570
  Show dependency treegraph
 
Reported: 2021-05-15 22:58 UTC by Dimitry Andric
Modified: 2021-06-06 18:16 UTC (History)
0 users

See Also:


Attachments
Fix googletest null pointer accesses (15.81 KB, text/plain)
2021-05-15 22:58 UTC, Dimitry Andric
no flags Details
Fix googletest null pointer accesses (15.61 KB, patch)
2021-05-15 23:02 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2021-05-15 22:58:45 UTC
Created attachment 224982 [details]
Fix googletest null pointer accesses

During an exp-run for llvm 12 (see bug 255570), it turned out that net-im/licq does not build with clang 12.0.0 [1]:

[ 92%] Running unit test
cd /wrkdirs/usr/ports/net-im/licq/work/.build/src && /usr/local/bin/ctest 
Test project /wrkdirs/usr/ports/net-im/licq/work/.build/src
    Start 1: licq
1/1 Test #1: licq .............................***Exception: SegFault  0.03 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.03 sec

The following tests FAILED:
	  1 - licq (SEGFAULT)
Errors while running CTest

This is due to licq using a relatively ancient version of googletest, which has a few issues with more modern compilers. In particular, it does not handle mocking methods with move-only return types, and in the case of this port, this leads to a null pointer access and consequently a segfault.

To fix the null pointer accesses, I needed to apply an upstream googletest commit [1]:

commit b5c81098a8ccc25e313ffca56c911200b3591ea0
Author: kosak <kosak@google.com>
Date:   Wed Jan 29 06:41:44 2014 +0000

    Support mocking methods with move-only return types.

and its prerequisite [2]:

commit 35956659eaaafd4b356acfbabcb48c183d957ff4
Author: kosak <kosak@google.com>
Date:   Wed Jan 29 06:34:44 2014 +0000

    Add GTEST_MOVE macro, to support mocking methods with move-only return types.
    Add GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_

Since some fuzz was needed to successfully apply them, I have attached a patch that resulted from "make makepatch". Now the test suite succeeds even under valgrind.

[1] http://package22.nyi.freebsd.org/data/mainamd64PR255570-default/2021-05-08_16h02m24s/logs/errors/licq-base-1.9.0_3.log
[2] https://github.com/google/googletest/commit/b5c81098a8ccc25e313ffca56c911200b3591ea0
[3] https://github.com/google/googletest/commit/35956659eaaafd4b356acfbabcb48c183d957ff4
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2021-05-15 23:02:10 UTC
Created attachment 224983 [details]
Fix googletest null pointer accesses

Attaching again, since bugzilla misdetected the file type.
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-06-06 18:15:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4572c48fc4d2a3326e85380b3f658dc8e1721817

commit 4572c48fc4d2a3326e85380b3f658dc8e1721817
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-05-15 22:49:52 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-06-06 18:13:58 +0000

    net-im/licq: apply googletest patches which fix null pointer accesses

    During an exp-run for llvm 12 (see bug 255570), it turned out that
    net-im/licq does not build with clang 12.0.0:

    [ 92%] Running unit test
    cd /wrkdirs/usr/ports/net-im/licq/work/.build/src && /usr/local/bin/ctest
    Test project /wrkdirs/usr/ports/net-im/licq/work/.build/src
        Start 1: licq
    1/1 Test #1: licq .............................***Exception: SegFault  0.03 sec

    This is due to licq using a relatively ancient version of googletest,
    which has a few issues with more modern compilers. In particular, it
    does not handle mocking methods with move-only return types, and in the
    case of this port, this leads to a null pointer access and consequently
    a segfault.

    To fix the null pointer accesses, apply a few upstream googletest
    commits.

    Approved by:    maintainer timeout (2 weeks)
    PR:             255915
    MFH:            2021Q2

 net-im/licq/Makefile                               |   2 +-
 ...party_gmock_include_gmock_gmock-actions.h (new) |  92 +++++++++++
 ...gmock_include_gmock_gmock-spec-builders.h (new) | 183 +++++++++++++++++++++
 ...ude_gmock_internal_gmock-internal-utils.h (new) |  38 +++++
 ...3rdparty_gmock_src_gmock-spec-builders.cc (new) |  29 ++++
 ...gtest_include_gtest_internal_gtest-port.h (new) |  34 ++++
 6 files changed, 377 insertions(+), 1 deletion(-)