Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix transport sdk crashed caused by jvm release the c-managed object #37

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions .github/workflows/cpp_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ jobs:
if: runner.os != 'Windows'
run: |
cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE ctest
make coverage

build_sdk:
name: build sdk
Expand Down Expand Up @@ -129,20 +128,24 @@ jobs:
- name: Build for macos
if: runner.os == 'macOS'
run: |
brew install lcov
bash cpp/tools/install_depends.sh -o macos
mkdir -p cpp/build && cd cpp/build && cmake -DTESTS=ON -DCOVERAGE=ON -DBUILD_SDK=ON -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake ../
mkdir -p cpp/build && cd cpp/build && cmake -DTESTS=ON -DCOVERAGE=OFF -DBUILD_SDK=ON -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake ../
make -j3
- name: Test
if: runner.os != 'Windows'
if: runner.os == 'macOS'
run: |
cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE make test
make coverage
- uses: actions/upload-artifact@v2
- name: Test and upload coverage
if: runner.os == 'Linux'
run: |
cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE make test
- uses: actions/upload-artifact@v4
if: runner.os == 'macos'
with:
name: libppc-crypto-sdk-jni.dylib
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.dylib
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: libppc-crypto-sdk-jni.dylib
Expand Down Expand Up @@ -185,7 +188,7 @@ jobs:
- name: Prepare vcpkg
if: runner.os != 'Windows'
uses: friendlyanon/setup-vcpkg@v1
with: { committish: 7e3dcf74e37034eea358934a90a11d618520e139 }
with: { committish: 51b14cd4e1230dd51c11ffeff6f7d53c61cc5297 }
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-07-28
Expand All @@ -206,19 +209,19 @@ jobs:
run: |
export OMP_NUM_THREADS=1
cd build && CTEST_OUTPUT_ON_FAILURE=TRUE make test
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: ppc-air-node-centos-x64
path: ./cpp/build/bin/ppc-air-node
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: ppc-pro-node-centos-x64
path: ./cpp/build/bin/ppc-pro-node
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: ppc-gateway-service-centos-x64
path: ./cpp/build/bin/ppc-gateway-service
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: libppc-crypto-sdk-jni.so
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so
2 changes: 1 addition & 1 deletion cpp/cmake/BuildInfo.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function(create_build_info)
# Set build platform; to be written to BuildInfo.h
set(PPC_BUILD_OS "${CMAKE_SYSTEM_NAME}")
set(PPC_BUILD_OS "${CMAKE_HOST_SYSTEM_NAME}")

if (CMAKE_COMPILER_IS_MINGW)
set(PPC_BUILD_COMPILER "mingw")
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake/CompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
add_compile_options(-fstack-protector)
add_compile_options(-Winconsistent-missing-override)
# Some Linux-specific Clang settings. We don't want these for OS X.
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
if ("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux")
# Tell Boost that we're using Clang's libc++. Not sure exactly why we need to do.
add_definitions(-DBOOST_ASIO_HAS_CLANG_LIBCXX)
# Use fancy colors in the compiler diagnostics
Expand Down
4 changes: 2 additions & 2 deletions cpp/cmake/Coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ function(config_coverage TARGET REMOVE_FILE_PATTERN)
message(STATUS "coverage REMOVE_FILE_PATTERN: " ${REMOVE_FILE_PATTERN})
if (APPLE)
add_custom_target(${TARGET}
COMMAND ${LCOV_TOOL} -keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -i -d ${CMAKE_BINARY_DIR}/
COMMAND ${LCOV_TOOL} -keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -d ${CMAKE_BINARY_DIR}/
COMMAND ${LCOV_TOOL} -keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -r ${CMAKE_BINARY_DIR}/coverage.info.in '*MacOS*' '/usr*' '.*vcpkg_installed*' '.*boost/*' '*test*' '*build*' '*deps*' ${REMOVE_FILE_PATTERN} -o ${CMAKE_BINARY_DIR}/coverage.info
COMMAND genhtml --keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -q -o ${CMAKE_BINARY_DIR}/CodeCoverage ${CMAKE_BINARY_DIR}/coverage.info)
else()
add_custom_target(${TARGET}
COMMAND ${LCOV_TOOL} --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -i -d ${CMAKE_BINARY_DIR}/
COMMAND ${LCOV_TOOL} --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -d ${CMAKE_BINARY_DIR}/
COMMAND ${LCOV_TOOL} --rc lcov_branch_coverage=1 -r ${CMAKE_BINARY_DIR}/coverage.info.in '*MacOS*' '/usr*' '.*vcpkg_installed*' '.*boost/*' '*test*' '*build*' '*deps*' ${REMOVE_FILE_PATTERN} -o ${CMAKE_BINARY_DIR}/coverage.info
COMMAND genhtml --rc lcov_branch_coverage=1 -q -o ${CMAKE_BINARY_DIR}/CodeCoverage ${CMAKE_BINARY_DIR}/coverage.info)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake/Installlibhdfs3.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_package(libxml2 REQUIRED)
find_package(protobuf REQUIRED)
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
if ("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux")
find_package(unofficial-libuuid REQUIRED)
endif()
find_package(libhdfs3 REQUIRED)
15 changes: 9 additions & 6 deletions cpp/cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ macro(configure_project)
if (${SUPPORTED_INSTRUCTIONS} MATCHES ".*SSE4.2.*")
set(ENABLE_SSE ON)
endif ()
elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
elseif(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Windows")
# detect sse4_2
FILE(READ "/proc/cpuinfo" SUPPORTED_INSTRUCTIONS)
message("* Linux SUPPORTED_INSTRUCTIONS: ${SUPPORTED_INSTRUCTIONS}")
if (${SUPPORTED_INSTRUCTIONS} MATCHES ".*sse4_2.*")
set(ENABLE_SSE ON)
endif ()
Expand Down Expand Up @@ -137,15 +138,17 @@ macro(configure_project)
if (BUILD_ALL)
# install all dependencies
list(APPEND VCPKG_MANIFEST_FEATURES "all")
if(ENABLE_SSE)
# enable sse for libhdfs3
list(APPEND VCPKG_MANIFEST_FEATURES "sse-libhdfs3")
else()
list(APPEND VCPKG_MANIFEST_FEATURES "default-libhdfs3")
endif()
endif()
if (BUILD_WEDPR_TOOLKIT)
# install wedpr dependencies
list(APPEND VCPKG_MANIFEST_FEATURES "toolkit")
endif()
if(ENABLE_SSE)
# enable sse for libhdfs3
list(APPEND VCPKG_MANIFEST_FEATURES "sse")
endif()
# cpp_features
if(ENABLE_CPU_FEATURES)
list(APPEND VCPKG_MANIFEST_FEATURES "cpufeatures")
Expand All @@ -164,7 +167,7 @@ macro(print_config NAME)
message("-- CMAKE_BUILD_TYPE Build type ${CMAKE_BUILD_TYPE}")
message("-- VCPKG_MANIFEST_FEATURES VCPKG manifest features ${VCPKG_MANIFEST_FEATURES}")
message("-- CMAKE_TOOLCHAIN_FILE Cmake toolchain file ${CMAKE_TOOLCHAIN_FILE}")
message("-- TARGET_PLATFORM Target platform ${CMAKE_SYSTEM_NAME} ${ARCHITECTURE}")
message("-- TARGET_PLATFORM Target platform ${CMAKE_HOST_SYSTEM_NAME} ${ARCHITECTURE}")
message("-- BUILD_STATIC Build static ${BUILD_STATIC}")
message("-- COVERAGE Build code coverage ${COVERAGE}")
message("-- TESTS Build tests ${TESTS}")
Expand Down
8 changes: 4 additions & 4 deletions cpp/ppc-framework/front/IFront.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class IFront : virtual public IFrontClient
std::string const& topic, ppc::protocol::MessageDispatcherCallback callback) = 0;

/////// to simplify SDK wrapper ////
virtual void registerTopicHandler(
virtual void register_topic_handler(
std::string const& topic, MessageDispatcherHandler::Ptr callback)
{
registerTopicHandler(topic, populateMessageDispatcherCallback(callback));
Expand All @@ -135,7 +135,7 @@ class IFront : virtual public IFrontClient
std::string const& componentType, ppc::protocol::MessageDispatcherCallback callback) = 0;

/////// to simplify SDK wrapper ////
virtual void registerMessageHandler(
virtual void register_msg_handler(
std::string const& componentType, MessageDispatcherHandler::Ptr callback)
{
registerMessageHandler(componentType, populateMessageDispatcherCallback(callback));
Expand Down Expand Up @@ -165,7 +165,7 @@ class IFront : virtual public IFrontClient

// !!! Note: the 'payload' type(char*) should not been changed, since it used to pass-in java
// byte[] data
virtual void asyncSendMessage(uint16_t routeType,
virtual void async_send_message(uint16_t routeType,
ppc::protocol::MessageOptionalHeader::Ptr const& routeInfo, char* payload,
uint64_t payloadSize, int seq, long timeout, ErrorCallback::Ptr errorCallback,
IMessageHandler::Ptr msgHandler)
Expand All @@ -183,7 +183,7 @@ class IFront : virtual public IFrontClient

// !!! Note: the 'payload ' type(char*) should not been changed, since it used to pass-in java
// byte[] data
virtual void asyncSendResponse(bcos::bytes const& dstNode, std::string const& traceID,
virtual void async_send_response(bcos::bytes const& dstNode, std::string const& traceID,
bcos::bytes&& payload, int seq, ErrorCallback::Ptr errorCallback)
{
asyncSendResponse(
Expand Down
6 changes: 3 additions & 3 deletions cpp/tools/install_depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ install_centos_depends()
{
LOG_INFO "install depends for centos ..."
# install the basic package
sudo yum install -y bison flex epel-release centos-release-scl flex bison patch devtoolset-11 rh-perl530-perl cmake3 zlib-devel ccache lcov python-devel python3-devel krb5-devel autoconf
sudo yum install -y lcov bison flex epel-release centos-release-scl flex bison patch devtoolset-11 rh-perl530-perl cmake3 zlib-devel ccache lcov python-devel python3-devel krb5-devel autoconf
LOG_INFO "install basic-package-depends for centos success..."

LOG_INFO "install gsasl ... "
Expand All @@ -85,7 +85,7 @@ install_ubuntu_depends()
{
LOG_INFO "install depends for ubuntu ..."
# install the basic package
sudo apt install -y bison flex g++ libssl-dev openssl cmake git build-essential autoconf texinfo flex patch bison libgmp-dev zlib1g-dev automake pkg-config libtool wget libkrb5-dev autoconf
sudo apt install -y lcov bison flex g++ libssl-dev openssl cmake git build-essential autoconf texinfo flex patch bison libgmp-dev zlib1g-dev automake pkg-config libtool wget libkrb5-dev autoconf
LOG_INFO "install basic-package-depends for ubuntu success..."

LOG_INFO "install gsasl ... "
Expand All @@ -106,7 +106,7 @@ install_ubuntu_depends()
install_macos_depends()
{
LOG_INFO "install depends for macos ..."
brew install clang cmake autoconf gsasl nasm
brew install clang cmake autoconf gsasl nasm lcov
LOG_INFO "install depends for macos success ..."
}

Expand Down
6 changes: 3 additions & 3 deletions cpp/vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"registries": [
{
"kind": "git",
"repository": "https://github.com/cyjseagull/registry",
"baseline": "6160f4167d4ab801f16a18bdd842a75edf7b069e",
"repository": "https://github.com/FISCO-BCOS/registry",
"baseline": "b483a0287c6ee7017983942af540e3ee672b0994",
"packages": [
"openssl",
"bcos-utilities",
Expand All @@ -13,4 +13,4 @@
]
}
]
}
}
26 changes: 21 additions & 5 deletions cpp/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
{
"name": "libhdfs3",
"version": "2024-04-27"
"version": "2024-04-27#1"
},
{
"name": "tbb",
Expand All @@ -58,8 +58,25 @@
}
],
"features": {
"sse": {
"description": "Enable SSE4.2 for libhdfs3"
"sse-libhdfs3": {
"description": "Enable SSE4.2 for libhdfs3",
"dependencies":[
{
"name": "libhdfs3",
"version>=": "2024-04-27#1",
"features": ["sse"]
}
]
},
"default-libhdfs3": {
"description": "Disable SSE4.2 for libhdfs3",
"dependencies":[
{
"name": "libhdfs3",
"version>=": "2024-04-27#1",
"features": []
}
]
},
"cpufeatures":{
"description": "Enable cpu features",
Expand Down Expand Up @@ -98,7 +115,6 @@
"name": "grpc",
"version>=": "1.51.1"
},
"libhdfs3",
"tarscpp",
"tbb",
"libxml2"
Expand All @@ -121,4 +137,4 @@
]
}
}
}
}
1 change: 1 addition & 0 deletions cpp/wedpr-main/common/NodeStarter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <execinfo.h>
#include <libhelper/CommandHelper.h>
#include <libhelper/ExitHandler.h>
#include <signal.h>
#include <stdexcept>
#include <thread>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@
import com.webank.wedpr.sdk.jni.transport.TransportConfig;
import com.webank.wedpr.sdk.jni.transport.WeDPRTransport;
import com.webank.wedpr.sdk.jni.transport.handlers.MessageDispatcherCallback;
import com.webank.wedpr.sdk.jni.transport.handlers.MessageErrorCallback;
import com.webank.wedpr.sdk.jni.transport.impl.TransportImpl;
import com.webank.wedpr.sdk.jni.transport.model.TransportEndPoint;

public class TransportDemo {
public static class MessageDispatcherCallbackImpl extends MessageDispatcherCallback {
private final String nodeID;

// java -cp 'conf/:lib/*:apps/*' com.webank.wedpr.sdk.jni.demo.TransportDemo agency0Node
// "127.0.0.1" 9020 "ipv4:127.0.0.1:40600,127.0.0.1:40601" "agency1Node"
// java -cp 'conf/:lib/*:apps/*' com.webank.wedpr.sdk.jni.demo.TransportDemo agency1Node
// "127.0.0.1" 9021 "ipv4:127.0.0.1:40620,127.0.0.1:40621" "agency0Node"
public MessageDispatcherCallbackImpl(String nodeID) {
this.nodeID = nodeID;
}
Expand All @@ -45,10 +50,10 @@ public void onMessage(IMessage message) {
}
}

public static class MessageErrorCallback extends ErrorCallback {
public static class MessageErrorCallbackImpl extends MessageErrorCallback {
private final String nodeID;

public MessageErrorCallback(String nodeID) {
public MessageErrorCallbackImpl(String nodeID) {
this.nodeID = nodeID;
}

Expand Down Expand Up @@ -101,7 +106,9 @@ public static void main(String[] args) throws Exception {

// send Message to the gateway
String topic = "testTopic";
transport.registerTopicHandler(topic, new MessageDispatcherCallbackImpl(nodeID));
MessageDispatcherCallback messageDispatcherCallback =
new MessageDispatcherCallbackImpl(nodeID);
transport.registerTopicHandler(topic, messageDispatcherCallback);
System.out.println("##### register topic success");

byte[] dstNodeBytes = dstNode.getBytes();
Expand All @@ -118,7 +125,7 @@ public static void main(String[] args) throws Exception {
payLoad.getBytes(),
0,
10000,
new MessageErrorCallback(nodeID),
new MessageErrorCallbackImpl(nodeID),
null);

// push
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ public SWIGTYPE_p_std__vectorT_std__string_t mutableComponents() {
return new SWIGTYPE_p_std__vectorT_std__string_t(
wedpr_java_transportJNI.FrontConfig_mutableComponents(swigCPtr, this), false);
}

public void disOwnMemory() {
swigSetCMemOwn(false);
}
}
Loading
Loading