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

spdlog::basic_logger_st crash on qt 6.8.0 #3211

Closed
ax4688 opened this issue Oct 10, 2024 · 6 comments
Closed

spdlog::basic_logger_st crash on qt 6.8.0 #3211

ax4688 opened this issue Oct 10, 2024 · 6 comments

Comments

@ax4688
Copy link

ax4688 commented Oct 10, 2024

try { QString _name = tr("Modbus"); QString _logpath = QString("%1/log/%2/%3.txt").arg(qApp->applicationDirPath(),_name,QDate::currentDate().toString("yyyy-MM-dd")); std::shared_ptr<spdlog::logger> _log = spdlog::basic_logger_st(_name.toLocal8Bit().data(), _logpath.toLocal8Bit().data()); } catch (const spdlog::spdlog_ex &_ex) { qDebug() << __FILE__ << __FUNCTION__ << __LINE__ ; qDebug() << "basic_logger_st fail:" << _ex.what(); }
the above code works well on Qt5.15.2 and Qt6.7.0,but it keeps crashing afer upgrading to 6.8.The development environment is win11,i7-12700h,16G(it also runs well),The operating environment is win10,i5-1135g7,8g(This device always crashes and abnormalities cannot be captured),Please help me, thank you!

@tt4g
Copy link
Contributor

tt4g commented Oct 10, 2024

What error message (_ex.what()) did you see?

EDIT: By the way, if you upgraded Qt and now it crashes, then it is a Qt problem.
Shouldn't you ask this question in the Qt community?

@ax4688
Copy link
Author

ax4688 commented Oct 11, 2024

[]> What error message (_ex.what()) did you see?

EDIT: By the way, if you upgraded Qt and now it crashes, then it is a Qt problem. Shouldn't you ask this question in the Qt community?

_ex.what() Unable to capture and reality;but the way,I compiled the same source code using VS2022, and on that testing device, it also crashed,When I compiled using vs2019, it ran well on that testing [device;]

@ax4688
Copy link
Author

ax4688 commented Oct 11, 2024

微信截图_20241011101840
try { std::cout << __FILE__ << __FUNCTION__ << __LINE__ << std::endl; std::string _name = "Modbus"; std::cout << __FILE__ << __FUNCTION__ << __LINE__ << std::endl; std::string _logpath = "D:/log/Modbus/2024-10-11.txt"; std::cout << __FILE__ << __FUNCTION__ << __LINE__ << std::endl; std::shared_ptr<spdlog::logger> _log = spdlog::basic_logger_st(_name, _logpath); std::cout << __FILE__ << __FUNCTION__ << __LINE__ << std::endl; } catch (const spdlog::spdlog_ex& _ex) { std::cout << __FILE__ << __FUNCTION__ << __LINE__ << std::endl; std::cout << "basic_logger_st fail:" << _ex.what() << std::endl; }
Whether using QT6.8(build by vs2022) or VS2022, this code will definitely crash on the testing device and the exception will prevent printing;the sampe code works well on VS2019

@ax4688
Copy link
Author

ax4688 commented Oct 11, 2024

The phenomenon I found here is that VS2019 can run when compiled, but VS2022 will definitely crash on the testing device. If needed, I can provide remote access to the testing device (todesk or 向日葵)

@tt4g
Copy link
Contributor

tt4g commented Oct 11, 2024

If the cause of the crash is throw inside spdlog (even if it is std::bad_alloc), spdlog::spdlog_ex is used and can be covered with catch (const spdlog::spdlog_ex&).
As long as _ex.what() is evaluated and no error messages are printed, spdlog is not the cause.

@tt4g
Copy link
Contributor

tt4g commented Oct 11, 2024

The phenomenon I found here is that VS2019 can run when compiled, but VS2022 will definitely crash on the testing device.

If the Qt upgrade is unrelated and the MSVC version is triggering the problem, then it is possible that #3145 is a duplicate.

Is it possible that the version of MSVC runtime on the development machine and the test device do not match?

See also:

@ax4688 ax4688 closed this as completed Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants