Skip to content

Commit

Permalink
Merge tag 'v14.12.1' into feature/local-only
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Aug 30, 2024
2 parents 6bec459 + b36f243 commit b61ebdb
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 20 deletions.
30 changes: 27 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Using an empty KeyPath in C API would result in no filtering being done ([#7805](https://github.com/realm/realm-core/issues/7805), since 13.24.0)
* Filtering notifications with backlink columns as last element could sometimes give wrong results ([#7530](https://github.com/realm/realm-core/issues/7530), since 11.1.0)
* Fix crash during client app shutdown when Logger log level is set higher than Info. ([#7969](https://github.com/realm/realm-core/issues/7969), since v13.23.3)
* None.

### Breaking changes
* Ability to synchronize has been removed.
Expand All @@ -18,6 +16,32 @@

-----------

### Internals
* None.

----------------------------------------------

# 14.12.1 Release notes

### Enhancements
* None.

### Fixed
* Using an empty KeyPath in C API would result in no filtering being done ([#7805](https://github.com/realm/realm-core/issues/7805), since v13.24.0)
* Filtering notifications with backlink columns as last element could sometimes give wrong results ([#7530](https://github.com/realm/realm-core/issues/7530), since v11.1.0)
* Fix crash during client app shutdown when Logger log level is set higher than Info. ([#7969](https://github.com/realm/realm-core/issues/7969), since v13.23.3)
* If File::rw_lock() fails to open a file the exception message does not contain the filename ([#7999](https://github.com/realm/realm-core/issues/7999), since v6.0.21)
* Fallback to hashed filename will fail if length of basename is between 240 and 250 ([#8007](https://github.com/realm/realm-core/issues/8007), since v10.0.0)
* Swift API misuse within a callback from core would result in an internal unreachable error rather than the exception being propagated properly ([#7836](https://github.com/realm/realm-core/issues/7836)).

### Breaking changes
* None.

### Compatibility
* Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.

-----------

### Internals
* Update TestAppSession to allow scope-based usage for restarting the local app resources. ([PR #7672](https://github.com/realm/realm-core/pull/7672))

Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import PackageDescription
import Foundation

let versionStr = "14.12.0"
let versionStr = "14.12.1"
let versionPieces = versionStr.split(separator: "-")
let versionCompontents = versionPieces[0].split(separator: ".")
let versionExtra = versionPieces.count > 1 ? versionPieces[1] : ""
Expand Down Expand Up @@ -57,6 +57,7 @@ let notSyncServerSources: [String] = [
"realm/disable_sync_to_disk.cpp",
"realm/error_codes.cpp",
"realm/exceptions.cpp",
"realm/exceptions.mm",
"realm/geospatial.cpp",
"realm/global_key.cpp",
"realm/group.cpp",
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME: realm-core
VERSION: 14.12.0
VERSION: 14.12.1
OPENSSL_VERSION: 3.3.1
ZLIB_VERSION: 1.2.13
# https://github.com/10gen/baas/commits
Expand Down
4 changes: 4 additions & 0 deletions src/realm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ if(NOT MSVC)
list(APPEND REALM_SOURCES util/interprocess_mutex.cpp)
endif()

if(APPLE)
list(APPEND REALM_SOURCES exceptions.mm)
endif()

if (REALM_ENABLE_GEOSPATIAL)
list(APPEND REALM_SOURCES geospatial.cpp)
list(APPEND REALM_INSTALL_HEADERS geospatial.hpp)
Expand Down
3 changes: 3 additions & 0 deletions src/realm/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Exception::Exception(Status status)
{
}

// Apple implementation in exceptions.mm
#if !REALM_PLATFORM_APPLE
Status exception_to_status() noexcept
{
try {
Expand All @@ -80,6 +82,7 @@ Status exception_to_status() noexcept
REALM_UNREACHABLE();
}
}
#endif // !REALM_PLATFORM_APPLE

UnsupportedFileFormatVersion::UnsupportedFileFormatVersion(int version)
: Exception(ErrorCodes::UnsupportedFileFormatVersion,
Expand Down
45 changes: 45 additions & 0 deletions src/realm/exceptions.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*************************************************************************
*
* Copyright 2024 Realm Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**************************************************************************/

#include <realm/exceptions.hpp>

#include <realm/util/demangle.hpp>

#include <Foundation/Foundation.h>

namespace realm {
Status exception_to_status() noexcept
{
try {
throw;
}
catch (NSException* e) {
return Status(ErrorCodes::UnknownError, e.reason.UTF8String);
}
catch (const Exception& e) {
return e.to_status();
}
catch (const std::exception& e) {
return Status(ErrorCodes::UnknownError,
util::format("Caught std::exception of type %1: %2", util::get_type_name(e), e.what()));
}
catch (...) {
REALM_UNREACHABLE();
}
}
} // namespace realm
11 changes: 8 additions & 3 deletions src/realm/util/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,11 @@ bool File::rw_lock(bool exclusive, bool non_blocking)
// or the OS will deadlock when un-suspending the app.
int mode = exclusive ? O_WRONLY | O_NONBLOCK : O_RDWR | O_NONBLOCK;

auto report_err = [this](int err, const char* msg) {
auto message = util::format("%1: %2, path = '%3'", msg, std::system_category().message(err), m_fifo_path);
throw RuntimeError(ErrorCodes::FileOperationFailed, message); // LCOV_EXCL_LINE
};

// Optimistically try to open the fifo. This may fail due to the fifo not
// existing, but since it usually exists this is faster than trying to create
// it first.
Expand All @@ -1168,7 +1173,7 @@ bool File::rw_lock(bool exclusive, bool non_blocking)
}

// Otherwise we got an unexpected error
throw std::system_error(err, std::system_category(), "opening lock fifo for writing failed");
report_err(err, "opening lock fifo for writing failed");
}

if (err == ENOENT) {
Expand All @@ -1178,15 +1183,15 @@ bool File::rw_lock(bool exclusive, bool non_blocking)
try_make_dir(m_fifo_dir_path);
status = mkfifo(m_fifo_path.c_str(), 0666);
if (status != 0)
throw std::system_error(errno, std::system_category(), "creating lock fifo for reading failed");
report_err(errno, "creating lock fifo for reading failed");

// Try again to open the fifo now that it exists
fd = ::open(m_fifo_path.c_str(), mode);
err = errno;
}

if (fd == -1)
throw std::system_error(err, std::system_category(), "opening lock fifo for reading failed");
report_err(err, "opening lock fifo for reading failed");
}

// We successfully opened the pipe. If we're trying to acquire an exclusive
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ if (REALM_ENABLE_GEOSPATIAL)
list(APPEND CORE_TEST_SOURCES test_query_geo.cpp)
endif()

if (APPLE)
list(APPEND CORE_TEST_SOURCES test_nsexception.mm)
endif()

set(LARGE_TEST_SOURCES
large_tests/test_column_large.cpp
large_tests/test_strings.cpp)
Expand Down
16 changes: 5 additions & 11 deletions test/object-store/util/test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,14 @@ std::ostream& operator<<(std::ostream& os, const Exception& e)
return os;
}

bool create_dummy_realm(std::string path, std::shared_ptr<Realm>* out)
void create_dummy_realm(std::string path, std::shared_ptr<Realm>* out)
{
Realm::Config config;
config.path = path;
try {
auto realm = _impl::RealmCoordinator::get_coordinator(path)->get_realm(config, none);
REQUIRE_REALM_EXISTS(path);
if (out) {
*out = std::move(realm);
}
return true;
}
catch (std::exception&) {
return false;
auto realm = _impl::RealmCoordinator::get_coordinator(path)->get_realm(config, none);
REQUIRE_REALM_EXISTS(path);
if (out) {
*out = std::move(realm);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/object-store/util/test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ std::ostream& operator<<(std::ostream&, const Exception&);

class Realm;
/// Open a Realm at a given path, creating its files.
bool create_dummy_realm(std::string path, std::shared_ptr<Realm>* out = nullptr);
void create_dummy_realm(std::string path, std::shared_ptr<Realm>* out = nullptr);
std::vector<char> make_test_encryption_key(const char start = 0);
void catch2_ensure_section_run_workaround(bool did_run_a_section, std::string section_name,
util::FunctionRef<void()> func);
Expand Down
39 changes: 39 additions & 0 deletions test/test_nsexception.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*************************************************************************
*
* Copyright 2024 Realm Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**************************************************************************/

#include "test.hpp"

#include "realm/status.hpp"

#include <Foundation/Foundation.h>

namespace realm {
namespace {
TEST(Status_NSException)
{
try {
@throw [NSException exceptionWithName:@"Exception Name" reason:@"Expected reason" userInfo:nil];
}
catch (...) {
auto status = exception_to_status();
CHECK_EQUAL(status.code(), ErrorCodes::UnknownError);
CHECK_EQUAL(status.reason(), "Expected reason");
}
}
} // namespace
} // namespace realm

0 comments on commit b61ebdb

Please sign in to comment.