Crash in wxChartViewer::Render
I ran into an issue where the program would occasionally crash in the Render function with a read access violation error code. The problem seems to be in the underlying SetOutputOptions ChartDirector function, which seems to have an overflow error when reading the input strings. In rare cases, this overflow results in a crash. Adding a trailing semicolon to the input string to SetOutputOptions avoids the overflow and crash. I only tested this for the case where dpi > 0; I do not know whether there is a similar overflow when only the alpha value is provided. Issue occurred on win64 using the ChartDirector static library (chartdir70.lib), using MSVC. Have not tested on other platforms.
Up to now I wasn't able to reproduce the problem.
Could you please provide some more information. Which version of MSVC do you use? In which builds do crashes occur? Debug builds and/or release builds? Which compiler options are you using?
I'm using MSVC version 19.34.31937 for x86. Crash occurs in both debug (optimization disabled) and release (O2 optimization) builds. Most of our compiler options are left to the default, but we're using C++ 17 if that's relevant.
It may be difficult to reproduce the problem; it seems that, while the overflow occurs every time Render() is called (as far as I can tell), it is usually harmless, and only results in a crash when it runs into a section of invalid memory. I'm not sure what causes the invalid memory (possibly a cache coherency issue? the crash only showed up when we introduced multithreading).
If it would help, you can check out the exact project where we experienced the issue. It's public at https://github.com/silicondosa/telecon (commit hash: 21017b2f0394e065e6af37030027dad4d8d4650d). If you set the wxwin environment variable to your wxWidgets directory, and run the project telecon for about 2-5 minutes, it should crash.
If you're not able/willing to run our project or still can't reproduce the issue, please let me know and I'll try to see if I can produce a minimal program that exhibits it.
I'm using MSVC version 19.34.31937 for x86. Crash occurs in both debug (optimization disabled) and release (O2 optimization) builds. Most of our compiler options are left to the default, but we're using C++ 17 if that's relevant. [...]
Thanks for the details.
In the meantime I contacted the ChartDirector developers. They confirmed that there is most likely a bug in the ChartDirector library code, and they will release an updated DLL. Always using a trailing semicolon avoids the issue. Therefore I will modify the wxChartDir code accordingly - at least until an updated ChartDirector DLL will be available.
If you're not able/willing to run our project or still can't reproduce the issue, please let me know and I'll try to see if I can produce a minimal program that exhibits it.
For now, I will wait for the updated ChartDirector DLL. However, I will try to verify with your project that the new DLL solves the issue. I'll get back to you if I need assistance.
Great, thank you for the help!