Exception Related to String Encoding?

Discuss anything related to product development
Post Reply
jeffw
Posts: 5
Joined: Sun Jan 01 2023 6:52 pm

Exception Related to String Encoding?

Post by jeffw »

Hello All,

I have an application that the first thing it does is set the application name, but that results in a runtime exception
(Built Copperpsice 1.8.1 from source with MSVC 2019 in 64-bit and am using this version for my program)

#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("JWC"); <--Triggers Exception Below

In cs_string.h at line 686
*this = CsBasicString::fromUtf8(str, N-1, a)

Unhandled exception at 0x00007FFD4F8DDF28 (ucrtbase.dll) in JWC.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.

Do I have something mis-configured related to UTF-8 or Unicode?

Hoping someone can help me.

Jeff
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Exception Related to String Encoding?

Post by barbara »

a.setApplicationName("JWC")

Runtime exception (Built Copperpsice 1.8.1 from source with MSVC 2019 in 64-bit and am using this version for my program)
We have tested your code on MSVC 19.29.30147 in release mode and we have no compiler errors.

1 Is there a way for you to test on this exact version of MSVC?

2 Are you building both CopperSpice and your application in release mode?

3 Have you built your application with our pre-built CS binary files?


Barbara
jeffw
Posts: 5
Joined: Sun Jan 01 2023 6:52 pm

Re: Exception Related to String Encoding?

Post by jeffw »

Thanks for the response,

If I look on the Microsoft site, I see the latest VS 2019 Professional is 16.11

I cannot find any reference to 19.29.30147
Perhaps I am looking in the wrong place? Is this for a sub-component?

I really appreciate all of your help,
Jeff
ansel
Posts: 152
Joined: Fri Apr 10 2015 8:23 am

Re: Exception Related to String Encoding?

Post by ansel »

If I look on the Microsoft site, I see the latest VS 2019 Professional is 16.11

I cannot find any reference to 19.29.30147
Perhaps I am looking in the wrong place?
In our CI, we use VS 2019 version 16.11.23. If you run cl.exe you will see the actual version of the compiler, which is where you will find the 19.29.30147 version number.
Ansel Sermersheim
CopperSpice Cofounder
jeffw
Posts: 5
Joined: Sun Jan 01 2023 6:52 pm

Re: Exception Related to String Encoding?

Post by jeffw »

Thanks, I am not used to thinking of the command line compiler in windows but that makes sense.

if I follow the instructions on compiling with MSVC on the CS spice website everything goes smoothly.
(Originally I tried to compile with CMAKE-GUI)

The problem comes when I try to compile my application using CMake-GUI
This has been the way I have been compiling my applications and linking with Qt for a long time now.
With this method, cmake creates a solution using the MSVC build system and properly links to the Qt libraries.
Previously, when I generated with CMake-GUI, compiled and ran my program with Qt in Release mode it worked.
Within Visual Studio (MSVC build system), you can change between debug and release mode using a drop-down in VS without re-generating in Cmake.
With this method I could run in Debug mode and the application still worked, but there were no symbols defined to debug Qt related code.

In Copperspice it appears that both the application and copperspice libraries have to both be Release or Debug mode.
I assume this is because it uses the Ninja is build system to be compatible with other Operating Systems?

I was able to use Cmake-GUI to link my program in Debug mode with Copperspice and it all worked, but the application was extremely slow due to the CS code being debug code or incompatibilities between the MSVC build system and Ninja.

Is there a similar way to link a Debug application to the Release libraries in Copperspice?

Thanks again,
You guys are awesome.

Jeff
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: Exception Related to String Encoding?

Post by barbara »

In Copperspice it appears that both the application and copperspice libraries have to both be Release or Debug mode.
Yes, both CS and your application need to be in the same mode. Typically this is not an issue since debug builds are not distributed.
I assume this is because it uses the Ninja . . .
You are correct, Ninja only supports one type of build at a time.
... and it all worked, but the application was extremely slow due to the CS code being debug code . . .
Both CopperSpice and your application are in Debug mode, which adds a lot of symbols. Debug is always slower than release mode. If you need to test in debug mode their are always a few sacrifices and this happens on every platform.

As a silly side comment, we do a far bit of testing with Valgrind on Debian. Wow is that slow. <g>
Is there a similar way to link a Debug application to the Release libraries in Copperspice?
(1) CopperSpice uses the STL containers and the implementations of those containers are not ABI compatible between Debug and Release run times in MSVC. This limitation does not exist when compiling with gcc or clang on Unix. It is also not an issue using MinGW on Windows, which is another option for you to consider.

(2) You may also want to think about building CS in "Release" mode and your application in "RelWithDebInfo" mode. These both use the release run time but will allow you to do some debugging of your application.

(3) Another option is to build both the Debug and Release of CopperSpice. Make sure to install these to different directories.
When building your application, put both of the CS install folder names in your CMAKE_PREFIX_PATH. Your application will then choose the correct Debug or Release CS files, based on the mode you are using for your application.

Barbara
Post Reply