forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InteractionModelEngine][MemoryCorruption]
- Loading branch information
1 parent
14a98e9
commit d504039
Showing
13 changed files
with
453 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
import("//build_overrides/build.gni") | ||
|
||
# The location of the build configuration file. | ||
buildconfig = "${build_root}/config/BUILDCONFIG.gn" | ||
|
||
# CHIP uses angle bracket includes. | ||
check_system_includes = true | ||
|
||
default_args = { | ||
import("//args.gni") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
|
||
import("${chip_root}/config/standalone/args.gni") | ||
import("${chip_root}/build/chip/tools.gni") | ||
import("${chip_root}/build/config/mac/mac_sdk.gni") | ||
import("${chip_root}/src/lib/core/core.gni") | ||
|
||
assert(chip_build_tools) | ||
|
||
config("config-success") { | ||
include_dirs = [ | ||
".", | ||
"${chip_root}/src/lib", | ||
] | ||
} | ||
|
||
executable("memory-debug-success") { | ||
sources = [ "main-success.mm" ] | ||
|
||
public_configs = [ ":config-success" ] | ||
|
||
deps = [ | ||
"${chip_root}/src/controller/data_model", | ||
"${chip_root}/src/lib", | ||
"${chip_root}/src/platform/logging:stdio", | ||
] | ||
|
||
output_dir = root_out_dir | ||
} | ||
|
||
output_sdk_type = "Debug" | ||
|
||
action("build-memory-debug-failure") { | ||
script = "${chip_root}/scripts/build/build_darwin_framework.py" | ||
|
||
inputs = [ | ||
"${chip_root}/src/darwin/Framework/CHIP", | ||
"${chip_root}/src/darwin/Framework/CHIP/zap-generated", | ||
"${chip_root}/src/darwin/Framework/Matter.xcodeproj", | ||
] | ||
|
||
args = [ | ||
"--project_path", | ||
rebase_path("${chip_root}/src/darwin/Framework/Matter.xcodeproj", | ||
root_build_dir), | ||
"--out_path", | ||
"macos_framework_output", | ||
"--target", | ||
"Matter Framework", | ||
"--log_path", | ||
rebase_path("${root_build_dir}/darwin_framework_build.log", root_build_dir), | ||
"--target_arch", | ||
mac_target_arch, | ||
] | ||
|
||
output_name = "Matter.framework" | ||
outputs = [ | ||
"${root_out_dir}/macos_framework_output/Build/Products/${output_sdk_type}/${output_name}", | ||
"${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/gen/include", | ||
"${root_build_dir}/darwin_framework_build.log", | ||
"${root_out_dir}/macos_framework_output/ModuleCache.noindex/", | ||
"${root_out_dir}/macos_framework_output/Logs", | ||
"${root_out_dir}/macos_framework_output/Index", | ||
"${root_out_dir}/macos_framework_output/Build", | ||
"${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/lib/libCHIP.a", | ||
] | ||
} | ||
|
||
config("config-failure") { | ||
include_dirs = [ | ||
".", | ||
"include", | ||
"${chip_root}/examples/common", | ||
"${chip_root}/examples/darwin-framework-tool/commands/common", | ||
"${chip_root}/zzz_generated/darwin-framework-tool", | ||
"${chip_root}/zzz_generated/controller-clusters", | ||
"${chip_root}/examples/chip-tool", | ||
"${chip_root}/zzz_generated/chip-tool", | ||
"${root_out_dir}/macos_framework_output/Build/Products/${output_sdk_type}/", | ||
] | ||
|
||
framework_dirs = [ | ||
"${root_out_dir}/macos_framework_output/Build/Products/${output_sdk_type}/", | ||
] | ||
|
||
defines = [ | ||
"CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>", | ||
# Disable availability annotations in Matter.framework headers because we | ||
# are not building against a system Matter.framework here anyway. | ||
"MTR_NO_AVAILABILITY=1", | ||
] | ||
|
||
cflags = [ | ||
"-Wconversion", | ||
"-fobjc-arc", | ||
] | ||
} | ||
|
||
executable("memory-debug-failure") { | ||
sources = [ | ||
"main-failure.mm", | ||
] | ||
|
||
deps = [ | ||
":build-memory-debug-failure", | ||
] | ||
|
||
ldflags = [ | ||
"-rpath", | ||
"@executable_path/macos_framework_output/Build/Products/${output_sdk_type}/", | ||
] | ||
|
||
frameworks = [ | ||
"Matter.framework", | ||
"Security.framework", | ||
] | ||
|
||
include_dirs = [ | ||
"${chip_root}/config/standalone/", | ||
"${chip_root}/src/", | ||
"${chip_root}/src/include/", | ||
"${root_gen_dir}/include", | ||
"${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/gen/include", | ||
] | ||
|
||
defines = [ | ||
"CHIP_HAVE_CONFIG_H=1", | ||
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1", | ||
] | ||
|
||
frameworks += [ | ||
"CoreFoundation.framework", | ||
"Foundation.framework", | ||
"CoreBluetooth.framework", | ||
"Network.framework", | ||
] | ||
|
||
# Other SDKs are linked statically to Matter.framework but the macosx SDK is linked dynamically but needs some symbols that are | ||
# not exposed by the dylib. | ||
libs = [ "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/lib/libCHIP.a" ] | ||
|
||
public_configs = [ ":config-failure" ] | ||
|
||
output_dir = root_out_dir | ||
} | ||
|
||
group("default") { | ||
deps = [ | ||
":memory-debug-success", | ||
":memory-debug-failure", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# 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. | ||
|
||
import("//build_overrides/chip.gni") | ||
|
||
import("${chip_root}/config/standalone/args.gni") | ||
|
||
chip_device_project_config_include = "<CHIPProjectAppConfig.h>" | ||
chip_project_config_include = "<CHIPProjectAppConfig.h>" | ||
chip_system_project_config_include = "<SystemProjectConfig.h>" | ||
|
||
chip_project_config_include_dirs = [ "${chip_root}/examples/chip-tool/include" ] | ||
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../build_overrides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2023 Project CHIP Authors | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* Project configuration for CHIP Tool. | ||
* | ||
*/ | ||
#ifndef CHIPPROJECTCONFIG_H | ||
#define CHIPPROJECTCONFIG_H | ||
|
||
#define CHIP_CONFIG_MAX_FABRICS 17 | ||
|
||
#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2 | ||
|
||
// Uncomment this for a large Tunnel MTU. | ||
// #define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (9000) | ||
|
||
// Enable support functions for parsing command-line arguments | ||
#define CHIP_CONFIG_ENABLE_ARG_PARSER 1 | ||
|
||
// Use a default pairing code if one hasn't been provisioned in flash. | ||
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 | ||
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 | ||
|
||
// Enable reading DRBG seed data from /dev/(u)random. | ||
// This is needed for test applications and the CHIP device manager to function | ||
// properly when CHIP_CONFIG_RNG_IMPLEMENTATION_CHIPDRBG is enabled. | ||
#define CHIP_CONFIG_DEV_RANDOM_DRBG_SEED 1 | ||
|
||
// For convenience, Chip Security Test Mode can be enabled and the | ||
// requirement for authentication in various protocols can be disabled. | ||
// | ||
// WARNING: These options make it possible to circumvent basic Chip security functionality, | ||
// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. | ||
// | ||
#define CHIP_CONFIG_SECURITY_TEST_MODE 0 | ||
|
||
#define CHIP_CONFIG_ENABLE_UPDATE 1 | ||
|
||
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 | ||
|
||
#define CHIP_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL 1 | ||
|
||
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY 1 | ||
|
||
// Enable some test-only interaction model APIs. | ||
#define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1 | ||
|
||
// Allow us, for test purposes, to encode invalid enum values. | ||
#define CHIP_CONFIG_IM_ENABLE_ENCODING_SENTINEL_ENUM_VALUES 1 | ||
|
||
#endif /* CHIPPROJECTCONFIG_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
#import <Matter/Matter.h> | ||
|
||
#include <pthread.h> | ||
|
||
void LogMessage(MTRLogType type, NSString * component, NSString * message) | ||
{ | ||
auto kLoggingColorError = @"\033[1;31m"; | ||
auto kLoggingColorProgress = @"\033[0;32m"; | ||
auto kLoggingColorDetail = @"\033[0;34m"; | ||
auto kLoggingColorEnd = @"\033[0m"; | ||
|
||
NSString * loggingColor = nil; | ||
|
||
switch (type) { | ||
case MTRLogTypeError: | ||
loggingColor = kLoggingColorError; | ||
break; | ||
case MTRLogTypeProgress: | ||
loggingColor = kLoggingColorProgress; | ||
break; | ||
case MTRLogTypeDetail: | ||
loggingColor = kLoggingColorDetail; | ||
break; | ||
} | ||
|
||
auto formatter = [[NSDateFormatter alloc] init]; | ||
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS"; | ||
auto formattedDate = [formatter stringFromDate:[NSDate date]]; | ||
|
||
int pid = [[NSProcessInfo processInfo] processIdentifier]; | ||
|
||
auto tid = pthread_mach_thread_np(pthread_self()); | ||
|
||
fprintf(stdout, "%s%s [%d:%u] [%s]: %s%s\n", loggingColor.UTF8String, formattedDate.UTF8String, pid, tid, | ||
component.UTF8String, message.UTF8String, kLoggingColorEnd.UTF8String); | ||
} | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
int exitCode = EXIT_SUCCESS; | ||
@autoreleasepool { | ||
MTRSetLogCallback(MTRLogTypeDetail, ^(MTRLogType type, NSString * component, NSString * message) { | ||
LogMessage(type, component, message); | ||
}); | ||
|
||
[MTRDeviceController hack]; | ||
} | ||
return exitCode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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 <app/InteractionModelEngine.h> | ||
|
||
@interface Test: NSObject | ||
- (void)run; | ||
@end | ||
|
||
@implementation Test | ||
- (void)run | ||
{ | ||
chip::app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(nullptr); | ||
} | ||
@end | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
int exitCode = EXIT_SUCCESS; | ||
@autoreleasepool { | ||
__auto_type test = [[Test alloc] init]; | ||
[test run]; | ||
} | ||
return exitCode; | ||
} |
Oops, something went wrong.