From cd6076dc302a1ce0b96ad07374c3df323d932174 Mon Sep 17 00:00:00 2001 From: James Antill Date: Mon, 8 Aug 2022 13:58:23 -0400 Subject: [PATCH] Import rpm: 4aae02b52a8ec6c9004000c37766a474d2b41ee1 --- .gitignore | 1 + ...r-Fix-undefined-behaviour-on-realloc.patch | 69 ++++++++++ ...r-fix-referencing-empty-array-rhel90.patch | 73 ++++++++++ README.md | 3 + gating.yaml | 6 + libpmemobj-cpp.rpmlintrc | 4 + libpmemobj-cpp.spec | 125 ++++++++++++++++++ sources | 1 + tests/.fmf/version | 1 + tests/libpmemobj-test-installed-libs.patch | 12 ++ tests/provision.fmf | 5 + tests/run_test.sh | 16 +++ tests/tests.yml | 24 ++++ 13 files changed, 340 insertions(+) create mode 100644 .gitignore create mode 100644 0001-vector-Fix-undefined-behaviour-on-realloc.patch create mode 100644 0002-vector-fix-referencing-empty-array-rhel90.patch create mode 100644 README.md create mode 100644 gating.yaml create mode 100644 libpmemobj-cpp.rpmlintrc create mode 100644 libpmemobj-cpp.spec create mode 100644 sources create mode 100644 tests/.fmf/version create mode 100644 tests/libpmemobj-test-installed-libs.patch create mode 100644 tests/provision.fmf create mode 100644 tests/run_test.sh create mode 100644 tests/tests.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..622a616 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/libpmemobj-cpp-1.11.tar.gz diff --git a/0001-vector-Fix-undefined-behaviour-on-realloc.patch b/0001-vector-Fix-undefined-behaviour-on-realloc.patch new file mode 100644 index 0000000..fedc4bb --- /dev/null +++ b/0001-vector-Fix-undefined-behaviour-on-realloc.patch @@ -0,0 +1,69 @@ +From 41ddc88a80160050b0ac1a51cb258f8918edf9aa Mon Sep 17 00:00:00 2001 +From: "Lucas A. M. Magalhaes" +Date: Wed, 23 Jun 2021 15:05:50 -0300 +Subject: [PATCH] vector: Fix undefined behaviour on realloc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On tests listed bellow the reserve method is being called before any +allocation on the object therefore realloc being called without +any previous allocation. Inside realloc _data is being used with the +operator '[]', as it is nullptr at that moment it's an undefined +behaviour. + +This patch simply returns a call to alloc if _data is nullptr. + +This tests fails on PowerPC with Segmentation Fault because of this +issue: +segment_vector_array_expsize_assign_exceptions_oom_0_none +segment_vector_array_expsize_assign_exceptions_oom_0_memcheck +segment_vector_array_expsize_capacity_exceptions_oom_0_none +segment_vector_array_expsize_capacity_exceptions_oom_0_memcheck +segment_vector_array_expsize_modifiers_exceptions_oom_0_none +segment_vector_array_expsize_modifiers_exceptions_oom_0_memcheck +segment_vector_vector_expsize_assign_exceptions_oom_0_none +segment_vector_vector_expsize_assign_exceptions_oom_0_memcheck +segment_vector_vector_expsize_capacity_exceptions_oom_0_none +segment_vector_vector_expsize_capacity_exceptions_oom_0_memcheck +segment_vector_vector_expsize_modifiers_exceptions_oom_0_none +segment_vector_vector_expsize_modifiers_exceptions_oom_0_memcheck +segment_vector_vector_fixedsize_assign_exceptions_oom_0_none +segment_vector_vector_fixedsize_assign_exceptions_oom_0_memcheck + +Signed-off-by: Lucas A. M. Magalhães lamm@linux.ibm.com +--- + include/libpmemobj++/container/vector.hpp | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/include/libpmemobj++/container/vector.hpp b/include/libpmemobj++/container/vector.hpp +index f430ed50..9810220b 100644 +--- a/include/libpmemobj++/container/vector.hpp ++++ b/include/libpmemobj++/container/vector.hpp +@@ -2362,7 +2362,8 @@ vector::internal_insert(size_type idx, InputIt first, InputIt last) + * Private helper function. Must be called during transaction. Allocates new + * memory for capacity_new number of elements and copies or moves old elements + * to new memory area. If the current size is greater than capacity_new, the +- * container is reduced to its first capacity_new elements. ++ * container is reduced to its first capacity_new elements. If was never ++ * allocated behaves as an alloc call. + * + * param[in] capacity_new new capacity. + * +@@ -2381,6 +2382,13 @@ vector::realloc(size_type capacity_new) + { + assert(pmemobj_tx_stage() == TX_STAGE_WORK); + ++ /* ++ * If _data == nullptr this object has never allocated any memory ++ * so we need to behave as alloc instead. ++ */ ++ if (_data == nullptr) ++ return alloc(capacity_new); ++ + /* + * XXX: future optimization: we don't have to snapshot data + * which we will not overwrite +-- +2.27.0 + diff --git a/0002-vector-fix-referencing-empty-array-rhel90.patch b/0002-vector-fix-referencing-empty-array-rhel90.patch new file mode 100644 index 0000000..103aee0 --- /dev/null +++ b/0002-vector-fix-referencing-empty-array-rhel90.patch @@ -0,0 +1,73 @@ +diff --git a/include/libpmemobj++/container/vector.hpp b/include/libpmemobj++/container/vector.hpp +--- a/include/libpmemobj++/container/vector.hpp ++++ b/include/libpmemobj++/container/vector.hpp +@@ -668,7 +668,7 @@ vector::assign(size_type count, const_reference value) + add_data_to_tx(0, size_old); + + std::fill_n( +- &_data[0], ++ _data.get(), + (std::min)(count, + static_cast(size_old)), + value); +@@ -1600,7 +1600,7 @@ vector::insert(const_iterator pos, size_type count, const value_type &value) + single_element_iterator(&value, count)); + }); + +- return iterator(&_data[static_cast(idx)]); ++ return iterator(_data.get() + static_cast(idx)); + } + + /** +@@ -1843,7 +1843,7 @@ typename vector::iterator + vector::erase(const_iterator first, const_iterator last) + { + size_type idx = static_cast( +- std::distance(const_iterator(&_data[0]), first)); ++ std::distance(const_iterator(_data.get()), first)); + size_type count = static_cast(std::distance(first, last)); + + if (count == 0) +@@ -2306,10 +2306,11 @@ vector::internal_insert(size_type idx, InputIt first, InputIt last) + auto count = static_cast(std::distance(first, last)); + + if (_capacity >= size() + count) { +- pointer dest = +- &_data[static_cast(size() + count)]; +- pointer begin = &_data[static_cast(idx)]; +- pointer end = &_data[static_cast(size())]; ++ pointer dest = _data.get() + ++ static_cast(size() + count); ++ pointer begin = _data.get() + static_cast(idx); ++ pointer end = ++ _data.get() + static_cast(size()); + + add_data_to_tx(idx, size() - idx + count); + +@@ -2327,9 +2328,11 @@ vector::internal_insert(size_type idx, InputIt first, InputIt last) + + auto old_data = _data; + auto old_size = _size; +- pointer old_begin = &_data[0]; +- pointer old_mid = &_data[static_cast(idx)]; +- pointer old_end = &_data[static_cast(size())]; ++ pointer old_begin = _data.get(); ++ pointer old_mid = ++ _data.get() + static_cast(idx); ++ pointer old_end = ++ _data.get() + static_cast(size()); + + _data = nullptr; + _size = _capacity = 0; +@@ -2397,7 +2400,7 @@ vector::realloc(size_type capacity_new) + + auto old_data = _data; + auto old_size = _size; +- pointer old_begin = &_data[0]; ++ pointer old_begin = _data.get(); + pointer old_end = capacity_new < _size + ? &_data[static_cast(capacity_new)] + : &_data[static_cast(size())]; +-- +2.27.0 + diff --git a/README.md b/README.md new file mode 100644 index 0000000..de92a0b --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# libpmemobj-cpp + +The libpmemobj-cpp package \ No newline at end of file diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..648918d --- /dev/null +++ b/gating.yaml @@ -0,0 +1,6 @@ +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/libpmemobj-cpp.rpmlintrc b/libpmemobj-cpp.rpmlintrc new file mode 100644 index 0000000..77296d5 --- /dev/null +++ b/libpmemobj-cpp.rpmlintrc @@ -0,0 +1,4 @@ +# SPELLING ERRORS + +addFilter(r'spelling-error .* en_US (libpmemobj|transactional)') +addFilter(r'spelling-error .*\(en_US\) (libpmemobj|transactional)') diff --git a/libpmemobj-cpp.spec b/libpmemobj-cpp.spec new file mode 100644 index 0000000..3300ff5 --- /dev/null +++ b/libpmemobj-cpp.spec @@ -0,0 +1,125 @@ +%global min_libpmemobj_ver 1.11.1 +%global upstreamversion 1.11 + +Name: libpmemobj-cpp +Version: 1.11 +Release: 2%{?dist} +Summary: C++ bindings for libpmemobj +# Note: tests/external/libcxx is dual licensed using University of Illinois "BSD-Like" license and the MIT license. It's used only during development/testing and is NOT part of the binary RPM. +License: BSD +URL: http://pmem.io/pmdk/cpp_obj/ + +Source0: https://github.com/pmem/%{name}/archive/%{upstreamversion}.tar.gz#/%{name}-%{upstreamversion}.tar.gz + +BuildRequires: libpmemobj-devel >= %{min_libpmemobj_ver} +BuildRequires: cmake >= 3.3 +BuildRequires: glibc-devel +BuildRequires: gcc-c++ +BuildRequires: pkgconfig +BuildRequires: doxygen +BuildRequires: perl-Encode +BuildRequires: libatomic + +# There's nothing x86-64 specific in this package, but we have +# to duplicate what spec for pmdk/libpmemobj has at the moment. +# Relevant bug reports: +# https://bugzilla.redhat.com/show_bug.cgi?id=1340634 +# https://bugzilla.redhat.com/show_bug.cgi?id=1340635 +# https://bugzilla.redhat.com/show_bug.cgi?id=1340636 +# https://bugzilla.redhat.com/show_bug.cgi?id=1340637 +ExclusiveArch: x86_64 + +%description +This package contains header files for libpmemobj C++ bindings and C++ +containers built on top of them. + +# Specify a virtual Provide for libpmemobj++-static package, so the package +# usage can be tracked. +%package -n libpmemobj++-devel +Summary: C++ bindings for Persistent Memory Transactional Object Store library +Provides: libpmemobj++-static = %{version}-%{release} +Requires: libpmemobj-devel >= %{min_libpmemobj_ver} + +%description -n libpmemobj++-devel +This package contains header files for libpmemobj C++ bindings and C++ +containers built on top of them. + +The libpmemobj library provides a transactional object store, +providing memory allocation, transactions, and general facilities for +persistent memory programming. + +%files -n libpmemobj++-devel +%{_libdir}/pkgconfig/libpmemobj++.pc +%dir %{_includedir}/libpmemobj++ +%{_includedir}/libpmemobj++/*.hpp +%dir %{_includedir}/libpmemobj++/detail +%{_includedir}/libpmemobj++/detail/*.hpp +%dir %{_includedir}/libpmemobj++/container +%{_includedir}/libpmemobj++/container/*.hpp +%dir %{_includedir}/libpmemobj++/container/detail +%{_includedir}/libpmemobj++/container/detail/*.hpp +%dir %{_includedir}/libpmemobj++/experimental +%{_includedir}/libpmemobj++/experimental/*.hpp +%dir %{_libdir}/libpmemobj++ +%dir %{_libdir}/libpmemobj++/cmake +%{_libdir}/libpmemobj++/cmake/libpmemobj++-config-version.cmake +%{_libdir}/libpmemobj++/cmake/libpmemobj++-config.cmake + +%license LICENSE + +%doc ChangeLog README.md + +%package -n libpmemobj++-doc +Summary: HTML documentation for libpmemobj++ + +%description -n libpmemobj++-doc +HTML documentation for libpmemobj++. + +%files -n libpmemobj++-doc +%dir %{_docdir}/libpmemobj++ +%{_docdir}/libpmemobj++/* + +%license LICENSE + +%doc ChangeLog README.md + +%global debug_package %{nil} + +%prep +%setup -q + +%build + +mkdir build +cd build +%cmake .. -DCMAKE_INSTALL_DOCDIR=%{_docdir}/libpmemobj++ +%make_build + +%install +cd build +%make_install + +%changelog +* Thu Mar 10 2022 Bryan Gurney - 1.11-2 +- Add libatomic to BuildRequires +- Related: rhbz#2061720 + +* Wed Jan 26 2022 Bryan Gurney - 1.11-1 +- Update to upstream version 1.11 +- Related: rhbz#2009889 + +* Mon Feb 1 2021 Jeff Moyer - 1.9-1 +- Update to upstream version 1.9 +- get rid of % check, as the builtin tests now require packages we don't ship. +- Related: rhbz#1780389 + +* Tue Jun 18 2019 Jeff Moyer - 1.6-2.el8 +- new build to kick off gating tests +- Related: rhbz#1659659 + +* Mon Jun 17 2019 Jeff Moyer - 1.6-1.el8 +- initial RHEL8 import +- Resolves: rhbz#1659659 + +* Thu Nov 8 2018 Marcin Ślusarz - 1.5-1 +- Initial RPM release diff --git a/sources b/sources new file mode 100644 index 0000000..ac36d2d --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA1 (libpmemobj-cpp-1.11.tar.gz) = 21c1d08e7d7ca816ceece51d667e2f86e80e5e63 diff --git a/tests/.fmf/version b/tests/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/tests/libpmemobj-test-installed-libs.patch b/tests/libpmemobj-test-installed-libs.patch new file mode 100644 index 0000000..90ceba4 --- /dev/null +++ b/tests/libpmemobj-test-installed-libs.patch @@ -0,0 +1,12 @@ +--- libpmemobj-cpp-1.12/CMakeLists.txt.orig 2021-08-04 11:05:28.909569992 -0400 ++++ libpmemobj-cpp-1.12/CMakeLists.txt 2021-08-04 11:06:02.922687943 -0400 +@@ -272,9 +272,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR + DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpmemobj++/cmake) + + +-# set up project's include dir (our source 'include' dir) +-include_directories(include) +- + # Run checks for known issues, it's required to enable/disable some tests and examples. + # It has to be executed (included) here, when environment is fully set up, + # all packages are found and all paths/variables are set. diff --git a/tests/provision.fmf b/tests/provision.fmf new file mode 100644 index 0000000..62a6eba --- /dev/null +++ b/tests/provision.fmf @@ -0,0 +1,5 @@ +--- + +standard-inventory-qcow2: + qemu: + m: 2G diff --git a/tests/run_test.sh b/tests/run_test.sh new file mode 100644 index 0000000..d75dbe2 --- /dev/null +++ b/tests/run_test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +NRCPUS=$(getconf _NPROCESSORS_ONLN) +patchfile="$PWD/libpmemobj-test-installed-libs.patch" + +cd source + +patch -p1 < $patchfile + +mkdir build +cd build +cmake .. -DTESTS_USE_VALGRIND=OFF -DTESTS_LONG=OFF -DTESTS_USE_FORCED_PMEM=ON +make -j $NRCPUS + +ctest --output-on-failure diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..99e2734 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,24 @@ +- hosts: localhost + roles: + - role: standard-test-source + tags: + - always + - role: standard-test-basic + tags: + - atomic + - classic + required_packages: + - libpmemobj-devel + - libpmemobj++-devel + - gcc-c++ + - cmake + - make + - glibc-devel + - pkgconfig + - doxygen + - gdb + - perl-Encode + tests: + - regression: # Run tests + dir: . + run: ./run_test.sh