aws / aws/aws-sdk-cpp

Aws::Client::ClientConfiguration Region is Undefined in Release Configuration

Open
#2,669 10 comments 0 reactions 0 assignees View on GitHub
bug build-problem p3
Dominant language
C++
Stars
2.2k
Forks
1.2k
Avg merge
3d 14h
Merged PRs (30d)
12

Description

### Describe the bug

Let me first start off by stating that I don't think this is a bug, but I'm missing steps to fix something. The code that I am running is below, which works in Debug configuration but not Release:
```
#define USE_IMPORT_EXPORT
#define USE_WINDOWS_DLL_SEMANTICS

#include
#include
#include
#include
#include
#include

#include
#include
#include

#include "json.hpp"

using namespace std;
using namespace nlohmann;

int main() {
Aws::SDKOptions options;
Aws::InitAPI(options);

// Setup credentials
Aws::Auth::AWSCredentials credentials;
credentials.SetAWSAccessKeyId("id");
credentials.SetAWSSecretKey("secret");

// Setup config
Aws::Client::ClientConfigurationInitValues values;
values.shouldDisableIMDS = true;
Aws::Client::ClientConfiguration clientConfig;
clientConfig.region = Aws::String("us-east-2"); // xstring's Memmove failure
Aws::Lambda::LambdaClient client(credentials, clientConfig); // aws Optional.h copy failure

return 0;
}
```

This issue has already been addressed by this Stack Overflow post (https://stackoverflow.com/questions/57157624/aws-sdk-c-code-dont-work-on-release-build), where they needed to update their packages.

However, I built my packages from CMake, and I should have the latest code on the main branch, and yet I still run into undefined behavior using xstring's memmove when trying to override the clientConfig.region. My reproduction steps for building are down below, am I missing a step?

### Expected Behavior

I expect the code to work in Release Configuration as it did for Debug.

### Current Behavior

Release Configuration crashes on trying to override the region by assigning a new string.

### Reproduction Steps

Steps to build packages and link it to the project:
1. Get CMake 3.21.7 and add to PATH
2. C:\Users\Jason > git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
2.5 C:\Users\Jason > git submodule update --init --recursive
3. C:\Users\Jason > mkdir sdk_build
4. C:\Users\Jason > cd sdk_build
5. C:\Users\Jason\sdk_build > cmake "..\aws-sdk-cpp" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="C:/Program Files (x86)/aws-cpp-sdk-all"
6. C:\Users\Jason\sdk_build > cmake --build . --config=Release
7. C:\Users\Jason\sdk_build > cmake --install . --config=Release
8. In Visual Studio, add "C:\Program Files (x86)\aws-cpp-sdk-all\include" to Release Configuration: Additional Include Directories
9. In Visual Studio, add "aws-cpp-sdk-core.lib;aws-cpp-sdk-s3.lib;aws-c-auth.lib;aws-c-cal.lib;aws-c-common.lib;aws-c-compression.lib;aws-c-event-stream.lib;aws-checksums.lib;aws-c-http.lib;aws-c-io.lib;aws-c-mqtt.lib;aws-crt-cpp.lib;aws-c-s3.lib;aws-c-sdkutils.lib;aws-cpp-sdk-lambda.lib;%(AdditionalDependencies)" to Release Configuration: Additional Dependencies
10. Copy above libs and corresponding dependencies and add them to the project folder (next to main.cpp)
11. Build and run in Release mode.

### Possible Solution

I'm thinking I need to update per this post (https://stackoverflow.com/questions/57157624/aws-sdk-c-code-dont-work-on-release-build), but clearing everything, git cloning, and confirming I have the latest in the main branch using `git submodule update --init --recursive` does not fix my issue, so I need to update some other way.

### Additional Information/Context

_No response_

### AWS CPP SDK version used

Latest (1.11.162)

### Compiler and Version used

Visual Studio 17 2022

### Operating System and version

Windows 10, Version 22H2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.