段错误 (核心已转储) centos qt 程序打包部署时运行报错(centos7 centos stream9 Qt)

一、问题描述

  在部署yum 打好的rpm包时,yum install XXX 安装过程ok,但是无法启动

通过命令./XXX --no-sandbox   在root用户下,或./XXX.sh --no-sandbox 都报

段错误 (核心已转储)

[root@localhost admin]# ./XXX --no-sandbox
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
QObject::moveToThread: Current thread (0x1c4aa60) is not the object's thread (0x35a9470).
Cannot move to target thread (0x35a9480)
QObject::connect(QAction, Unknown): invalid nullptr parameter
段错误 (核心已转储)
[root@localhost admin]# 

二、分析过程

    不过经过分析,网上说发生这个错误,都是内存读取越界,一时没搞懂,意思是说,通一些方法可以仔细找出引起 “段错误(核心已转储)”的原因, 个人理解这是一个被动错误,就是说我们的自大的程序本身的错误导致,但是奇怪的事,我们的程序在开发机,其它机器上是好的,那怎么回事呢? 只有一种可能了,就是新安装的程序 环境,配置参数,或数据库初始化没有设置好?

我们只有仔细排查,整个安装过程中是否已将所有设置设置好

三、解决过程

      排查了,配置项发现个别电脑因为ld.so.conf 配置没有好,而导致 ”段错误(核心已转储)“

还有一个电脑是因为 mysql 初始化成功后,在profile中保存的 export MYSQL_PWD="*********"

这个应当是一个明文,不知道为什么变成了密文,并且不对导致的,修改后,重新运行数据库脚本后。再执行 ./XXX --no-sandbox 程序问题解决了,直接跑起来了

初始化XXXdb业务数据库-end---------------------------------------------------------------
[root@localhost shellscript]# grep "temporary password" /var/log/mysqld.log
2022-10-14T09:43:55.058347Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: r#j+u/lg+4dO
[root@localhost shellscript]# vim /etc/profile
[root@localhost shellscript]# sed -i "s/export MYSQL_PWD=\"$XXX_mysql_root_password\"/ /g" /etc/profile
        sed -i "s/export MYSQL_PWD=\"$PASSWORD\"/export MYSQL_PWD=\"$XXX_mysql_root_password\"/g" /etc/profile
[root@localhost shellscript]# vim /etc/profile
[root@localhost shellscript]#   sed -i "s/export MYSQL_PWD=\"r#j+u/lg+4dO\"/export MYSQL_PWD=\"$XXX@123456\"/g" /etc/profile
sed:-e 表达式 #1,字符 36:“s”的未知选项
[root@localhost shellscript]#   sed -i "s/export MYSQL_PWD=\"r#j+u\/lg+4dO\"/export MYSQL_PWD=\"$XXX@123456\"/g" /etc/profile
[root@localhost shellscript]# vim /etc/profile
[root@localhost shellscript]#   sed -i "s/export MYSQL_PWD=\"r#j+u\/lg+4dO\"/export MYSQL_PWD=\"XXX@123456\"/g" /etc/profile
[root@localhost shellscript]# vim /etc/profile
[root@localhost shellscript]#   sed -i "s/export MYSQL_PWD=\"r#j+u\/lg+4dO\"/export MYSQL_PWD=\"XXX@123456\"/g" /etc/profile
[root@localhost shellscript]# vim /etc/profile
[root@localhost shellscript]# 

 sed -i "s/export MYSQL_PWD=\"$PASSWORD\"/export MYSQL_PWD=\"$XXX_mysql_root_password\"/g" /etc/profile

   

数据库初始化密码-错误摘要
序号 摘要
转义前(原始) r#j+u/lg+4dO
转义后 r#j+u\/lg+4dO

 mysql 安装时初始化密码是一个随机字符,本次突然出出一个需要转义的字符 /   因为没有转义,组成更新替换语句时,shell报错,导致数据库初始化等一系列执行没有成功,

XXX 程序无法链接数据库,直接崩溃,导致的 ”段错误(核心已转储)“,至此问题,解决

后续再研究直接从 ”段错误(核心已转储)“的日志中反向查询问题方法?

以上只 是一个导致错误的具体例子,实际项目中可能会有多种情况,只能具体情况具体分析,见机行事了

四、总结

               只要报”段错误(核心已转储)“ 绝大多数据是因为 环境配置原因,或配置初始化原因,大家应当有印象,有时候报这个错误,后来突然又不见了,但是如果你在找不原因的时候,他就会一至出现,所以请兄弟们耐心把整个流程排查 一遍,应当可以不在受这个问题的困扰,谢谢!

猜你喜欢

转载自blog.csdn.net/wyj372/article/details/127382365
今日推荐