Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit e9c33d2

Browse files
Merge branch 'stable-1.8' into 'stable-1.9'
2 parents 4884e82 + 31b402d commit e9c33d2

9 files changed

Lines changed: 128 additions & 30 deletions

File tree

.github/workflows/gha.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
fetch-depth: 50
4444

4545
- name: Pull or rebuild the image
46-
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./pull-or-rebuild-image.sh
46+
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./pull-or-rebuild-image.sh rebuild
4747

4848
- name: Run the build
4949
run: cd $WORKDIR && ${{ matrix.CONFIG }} ./build.sh

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2018-2020, Intel Corporation
2+
# Copyright 2018-2021, Intel Corporation
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions

ChangeLog

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
Tue Jul 06 2021 Łukasz Stolarczuk <lukasz.stolarczuk@intel.com>
2+
3+
* Version 1.6.1
4+
5+
This release fixes minor bugs.
6+
7+
This is the last patch release for libpmemobj-cpp 1.6 version.
8+
Maintenance of this version is no longer supported.
9+
10+
Notable changes:
11+
- string: fix max_size() return value
12+
- allocation_flag: mark constructor as explicit
13+
- peristent_ptr: change ptr_offset_magic to be properly aligned
14+
- fix few headers' includes
15+
16+
Mon Jun 28 2021 Łukasz Stolarczuk <lukasz.stolarczuk@intel.com>
17+
18+
* Version 1.5.2
19+
20+
This release fixes minor bugs.
21+
22+
This is the last patch release for libpmemobj-cpp 1.5 version.
23+
Maintenance of this version is no longer supported.
24+
25+
Notable changes:
26+
- operator[] for contiguous_iterator takes signed integral instead of
27+
unsigned
28+
- throw an exception when pmemobj_mutex_unlock fail
29+
- fix crash when a previous transaction failed to start because of
30+
already taken lock.
31+
132
Fri Jan 31 2020 Szymon Romik <szymon.romik@intel.com>
233

334
* Version 1.9
@@ -121,7 +152,7 @@ Fri Mar 15 2019 Igor Chorążewicz <igor.chorazewicz@intel.com>
121152
- decrease number of persistent_ptr dereferences in
122153
make_persistent_array
123154

124-
Tue Feb 19 2018 Marcin Ślusarz <marcin.slusarz@intel.com>
155+
Tue Feb 19 2019 Marcin Ślusarz <marcin.slusarz@intel.com>
125156

126157
* Version 1.5.1
127158

include/libpmemobj++/container/detail/contiguous_iterator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2020, Intel Corporation
2+
* Copyright 2018-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -242,7 +242,7 @@ struct range_snapshotting_iterator
242242
{
243243
assert(data <= ptr);
244244

245-
if (snapshot_size > 0)
245+
if (snapshot_size && ptr)
246246
snapshot_range(ptr);
247247
}
248248

include/libpmemobj++/container/vector.hpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2020, Intel Corporation
2+
* Copyright 2018-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -672,7 +672,7 @@ vector<T>::assign(size_type count, const_reference value)
672672
add_data_to_tx(0, size_old);
673673

674674
std::fill_n(
675-
&_data[0],
675+
_data.get(),
676676
(std::min)(count,
677677
static_cast<size_type>(size_old)),
678678
value);
@@ -1604,7 +1604,7 @@ vector<T>::insert(const_iterator pos, size_type count, const value_type &value)
16041604
single_element_iterator<value_type>(&value, count));
16051605
});
16061606

1607-
return iterator(&_data[static_cast<difference_type>(idx)]);
1607+
return iterator(_data.get() + static_cast<difference_type>(idx));
16081608
}
16091609

16101610
/**
@@ -1847,7 +1847,7 @@ typename vector<T>::iterator
18471847
vector<T>::erase(const_iterator first, const_iterator last)
18481848
{
18491849
size_type idx = static_cast<size_type>(
1850-
std::distance(const_iterator(&_data[0]), first));
1850+
std::distance(const_iterator(_data.get()), first));
18511851
size_type count = static_cast<size_type>(std::distance(first, last));
18521852

18531853
if (count == 0)
@@ -2323,10 +2323,11 @@ vector<T>::internal_insert(size_type idx, InputIt first, InputIt last)
23232323
auto count = static_cast<size_type>(std::distance(first, last));
23242324

23252325
if (_capacity >= size() + count) {
2326-
pointer dest =
2327-
&_data[static_cast<difference_type>(size() + count)];
2328-
pointer begin = &_data[static_cast<difference_type>(idx)];
2329-
pointer end = &_data[static_cast<difference_type>(size())];
2326+
pointer dest = _data.get() +
2327+
static_cast<difference_type>(size() + count);
2328+
pointer begin = _data.get() + static_cast<difference_type>(idx);
2329+
pointer end =
2330+
_data.get() + static_cast<difference_type>(size());
23302331

23312332
add_data_to_tx(idx, size() - idx + count);
23322333

@@ -2344,9 +2345,11 @@ vector<T>::internal_insert(size_type idx, InputIt first, InputIt last)
23442345

23452346
auto old_data = _data;
23462347
auto old_size = _size;
2347-
pointer old_begin = &_data[0];
2348-
pointer old_mid = &_data[static_cast<difference_type>(idx)];
2349-
pointer old_end = &_data[static_cast<difference_type>(size())];
2348+
pointer old_begin = _data.get();
2349+
pointer old_mid =
2350+
_data.get() + static_cast<difference_type>(idx);
2351+
pointer old_end =
2352+
_data.get() + static_cast<difference_type>(size());
23502353

23512354
_data = nullptr;
23522355
_size = _capacity = 0;
@@ -2379,7 +2382,8 @@ vector<T>::internal_insert(size_type idx, InputIt first, InputIt last)
23792382
* Private helper function. Must be called during transaction. Allocates new
23802383
* memory for capacity_new number of elements and copies or moves old elements
23812384
* to new memory area. If the current size is greater than capacity_new, the
2382-
* container is reduced to its first capacity_new elements.
2385+
* container is reduced to its first capacity_new elements. If was never
2386+
* allocated behaves as an alloc call.
23832387
*
23842388
* param[in] capacity_new new capacity.
23852389
*
@@ -2398,6 +2402,13 @@ vector<T>::realloc(size_type capacity_new)
23982402
{
23992403
assert(pmemobj_tx_stage() == TX_STAGE_WORK);
24002404

2405+
/*
2406+
* If _data == nullptr this object has never allocated any memory
2407+
* so we need to behave as alloc instead.
2408+
*/
2409+
if (_data == nullptr)
2410+
return alloc(capacity_new);
2411+
24012412
/*
24022413
* XXX: future optimization: we don't have to snapshot data
24032414
* which we will not overwrite
@@ -2406,7 +2417,7 @@ vector<T>::realloc(size_type capacity_new)
24062417

24072418
auto old_data = _data;
24082419
auto old_size = _size;
2409-
pointer old_begin = &_data[0];
2420+
pointer old_begin = _data.get();
24102421
pointer old_end = capacity_new < _size
24112422
? &_data[static_cast<difference_type>(capacity_new)]
24122423
: &_data[static_cast<difference_type>(size())];

tests/memcheck-libunwind.supp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@
2121
obj:*libunwind*
2222
...
2323
}
24+
{
25+
libunwind calls glibc's setcontext on some architectures, e.g. ppc
26+
Memcheck:Addr8
27+
fun:setcontext*
28+
...
29+
}
30+
{
31+
libunwind exception suppresion
32+
Memcheck:Param
33+
write(buf)
34+
...
35+
obj:*libunwind*
36+
...
37+
}

tests/ptr/ptr.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2020, Intel Corporation
2+
* Copyright 2015-2021, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -385,6 +385,38 @@ test_base_ptr_casting(nvobj::pool<root> &pop)
385385
UT_ASSERT(0);
386386
}
387387
}
388+
389+
/*
390+
* test_offset_with_alignment -- test offset calculation within a hierarchy of
391+
* objects with different alignments
392+
*/
393+
void
394+
test_offset_alignment(nvobj::pool<root> &pop)
395+
{
396+
struct A {
397+
char a;
398+
};
399+
400+
struct B {
401+
uint64_t b;
402+
};
403+
404+
struct C : public A, public B {
405+
uint64_t c;
406+
};
407+
408+
try {
409+
nvobj::transaction::run(pop, [] {
410+
auto cptr = nvobj::make_persistent<C>();
411+
nvobj::persistent_ptr<B> bptr = cptr;
412+
UT_ASSERT((bptr.raw().off - cptr.raw().off) ==
413+
alignof(B));
414+
nvobj::delete_persistent<C>(cptr);
415+
});
416+
} catch (...) {
417+
UT_ASSERT(0);
418+
}
419+
}
388420
}
389421

390422
int
@@ -412,6 +444,7 @@ main(int argc, char *argv[])
412444
test_ptr_array(pop);
413445
test_offset(pop);
414446
test_base_ptr_casting(pop);
447+
test_offset_alignment(pop);
415448

416449
pop.close();
417450

travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ before_install:
2727
- echo $TRAVIS_COMMIT_RANGE
2828
- export HOST_WORKDIR=`pwd`
2929
- cd utils/docker
30-
- ./pull-or-rebuild-image.sh
30+
- ./pull-or-rebuild-image.sh rebuild
3131

3232
script:
3333
- ./build.sh

utils/docker/pull-or-rebuild-image.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#
3-
# Copyright 2016-2020, Intel Corporation
3+
# Copyright 2016-2021, Intel Corporation
44
#
55
# Redistribution and use in source and binary forms, with or without
66
# modification, are permitted provided that the following conditions
@@ -34,17 +34,18 @@
3434
# pull-or-rebuild-image.sh - rebuilds the Docker image used in the
3535
# current Travis build if necessary.
3636
#
37-
# The script rebuilds the Docker image if the Dockerfile for the current
38-
# OS version (Dockerfile.${OS}-${OS_VER}) or any .sh script from the directory
39-
# with Dockerfiles were modified and committed.
37+
# The script rebuilds the Docker image if:
38+
# 1. the Dockerfile for the current OS version (Dockerfile.${OS}-${OS_VER})
39+
# or any .sh script in the Dockerfiles directory were modified and committed, or
40+
# 2. "rebuild" param was passed as a first argument to this script.
4041
#
4142
# If the Travis build is not of the "pull_request" type (i.e. in case of
4243
# merge after pull_request) and it succeed, the Docker image should be pushed
4344
# to the Docker Hub repository. An empty file is created to signal that to
4445
# further scripts.
4546
#
4647
# If the Docker image does not have to be rebuilt, it will be pulled from
47-
# Docker Hub.
48+
# the Docker Hub.
4849
#
4950

5051
set -e
@@ -78,6 +79,18 @@ if [[ -z "$HOST_WORKDIR" ]]; then
7879
exit 1
7980
fi
8081

82+
# Path to directory with Dockerfiles and image building scripts
83+
images_dir_name=images
84+
base_dir=utils/docker/$images_dir_name
85+
86+
# If "rebuild" param is passed to the script, force rebuild
87+
if [[ "${1}" == "rebuild" ]]; then
88+
pushd ${images_dir_name}
89+
./build-image.sh ${OS}-${OS_VER}
90+
popd
91+
exit 0
92+
fi
93+
8194
# Find all the commits for the current build
8295
if [ -n "$CI_COMMIT_RANGE" ]; then
8396
commits=$(git rev-list $CI_COMMIT_RANGE)
@@ -94,10 +107,6 @@ files=$(for commit in $commits; do git diff-tree --no-commit-id --name-only \
94107
echo "Files modified within the commit range:"
95108
for file in $files; do echo $file; done
96109

97-
# Path to directory with Dockerfiles and image building scripts
98-
images_dir_name=images
99-
base_dir=utils/docker/$images_dir_name
100-
101110
# Check if committed file modifications require the Docker image to be rebuilt
102111
for file in $files; do
103112
# Check if modified files are relevant to the current build
@@ -106,7 +115,7 @@ for file in $files; do
106115
then
107116
# Rebuild Docker image for the current OS version
108117
echo "Rebuilding the Docker image for the Dockerfile.$OS-$OS_VER"
109-
pushd $images_dir_name
118+
pushd ${images_dir_name}
110119
./build-image.sh ${OS}-${OS_VER}
111120
popd
112121

0 commit comments

Comments
 (0)