目录
异常弹窗
- 且有时弹窗后点击中止,程序并不会停止运行
问题定位
- 打断点debug缩小范围,然后发现是一句调用spdlog库生成log文件的代码引发:
- 百度得到了一些解析,这个问题是因为对象在析构时不正确的释放内存导致,且该问题只在使用了动态库才会有
解决办法
- 但spdlog内的代码显然不好去碰,而且这个问题是因为我们链接了spdlog的动态库才会有,那么我们可以使用它的header-only,也就是仅头文件,直接静态编译进入我们的程序,不使用它的动态库了。
- 由于我的项目是用cmake构建,在CMakeLists.txt中,将原来的 spdlog::spdlog 改为 spdlog::spdlog_header_only 即可。
- 然后就发现fmt也来这个问题,我真是吐了
- 那就再加一句,fmt::fmt-header-only 也使用静态编译的方式引入fmt库
最后
- 回顾这个问题,百度上也有博客说应当注意,编译生成动态库应尽量使用 /MD 和 /MDd,避免/MT和/MTd。动态库中避免函数传入参数或返回值使用 std::string 类型,应当使用 std::string& 或 [const] char*。
- 其次,这个问题和编译时的选项有关
- 如果程序和动态库都使用 /MD 编译,则不会有问题
- 如果动态库使用/MT编译,则程序和动态库各自有一个堆,假设我们的程序调用了一个动态库中的一个函数 std::string get(); 而这个string的内存是由动态库分配,但我们的程序并不能区分这个内存是程序的还是动态库的,当对象生命周期结束,就会由程序调用析构函数去释放内存,因此出错。
- 因此解决办法还可以是避免我们的程序去析构动态库返回的string。比如动态库中的函数返回全局变量。
Its such as you learn my mind! You seem to know so much about this, such
as you wrote the e book in it or something. I feel that you simply can do with some % to power the message house a little
bit, but instead of that, that is fantastic blog. An excellent read.
I’ll certainly be back.
We’re a group of volunteers and opening a new scheme in our
community. Your web site offered us with valuable information to work on. You’ve done a formidable job and our whole community will
be grateful to you.
Hmm it looks like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I
submitted and say, I’m thoroughly enjoying your
blog. I as well am an aspiring blog blogger but I’m still
new to everything. Do you have any tips for rookie blog writers?
I’d definitely appreciate it.
Every weekend i used to pay a quick visit
this web site, because i wish for enjoyment, since this this web page conations in fact
good funny stuff too.
Hmm is anyone else experiencing problems with the pictures on this blog loading?
I’m trying to find out if its a problem on my end or
if it’s the blog. Any feed-back would be greatly appreciated.
Appreciate the recommendation. Let me try it out.
Write more, thats all I have to say. Literally, it seems as
though you relied on the video to make your point.
You obviously know what youre talking about, why waste your intelligence on just
posting videos to your weblog when you could be giving us something
informative to read?
I’ve been browsing online more than 3 hours today, yet I
never found any interesting article like yours.
It is pretty worth enough for me. In my view, if all
site owners and bloggers made good content as you did,
the web will be a lot more useful than ever before.
Hello, I think your blog might be having browser compatibility issues.
When I look at your blog in Safari, it looks fine but when opening in Internet Explorer, it has some
overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!
Hey! I just wanted to ask if you ever have any problems with hackers?
My last blog (wordpress) was hacked and I ended up losing many months of
hard work due to no data backup. Do you have any methods to prevent hackers?
I love it whenever people come together and share ideas.
Great blog, continue the good work!
My partner and I stumbled over here different website and thought I might as well check things out.
I like what I see so now i am following you.
Look forward to looking over your web page yet again.
My coder is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the expenses.
But he’s tryiong none the less. I’ve been using WordPress on a number of websites for about a
year and am concerned about switching to another platform.
I have heard excellent things about blogengine.net. Is there a way I can transfer all my wordpress posts into it?
Any kind of help would be greatly appreciated!
Hi there! Someone in my Facebook group shared this site with us
so I came to take a look. I’m definitely loving the information.
I’m bookmarking and will be tweeting this to my followers!
Fantastic blog and fantastic style and design.
you are really a good webmaster. The web site loading speed is amazing.
It seems that you’re doing any distinctive trick. In addition, The contents are masterwork.
you have performed a fantastic process in this subject!
Aw, this was an exceptionally nice post. Finding the time and actual effort to produce a great article… but what can I say… I procrastinate a lot and don’t seem to get anything done.
I am genuinely thankful to the holder of this web site who has shared
this fantastic paragraph at at this place.
We absolutely love your blog and find most of your post’s to
be exactly I’m looking for. Does one offer guest writers to write content in your case?
I wouldn’t mind writing a post or elaborating on many of the
subjects you write concerning here. Again, awesome website!
Hi! I’m at work browsing your blog from my
new iphone! Just wanted to say I love reading through your blog and look forward
to all your posts! Keep up the fantastic work!
Thank you, I have just been looking for info approximately this topic for ages and yours is the best
I’ve found out till now. But, what about the conclusion? Are you sure about the source?
Awesome blog you have here but I was wanting to know if you knew of any discussion boards that cover the same topics discussed in this article?
I’d really love to be a part of group where I can get feed-back from other knowledgeable individuals that share the same interest.
If you have any suggestions, please let me know. Thanks!
With havin so much content and articles do you ever run into any problems of plagorism or copyright infringement?
My website has a lot of unique content I’ve either written myself or
outsourced but it seems a lot of it is popping it up all over the internet without my agreement.
Do you know any methods to help reduce content from being stolen? I’d genuinely appreciate it.
Wow, this paragraph is fastidious, my younger sister is analyzing
such things, thus I am going to tell her.
Greetings, There’s no doubt that your web site might be
having web browser compatibility issues. When I look at
your website in Safari, it looks fine however when opening in I.E.,
it has some overlapping issues. I merely wanted
to provide you with a quick heads up! Aside from that, great site!
Very quickly this web page will be famous amid all blog users, due to it’s fastidious articles or reviews
Can you tell us more about this? I’d love to find out more details.
Wow, this article is good, my younger sister is analyzing these things, therefore I am going to convey her.
Hello There. I found your blog using msn. This is a really well written article.
I will make sure to bookmark it and come back to read more of your
useful information. Thanks for the post. I’ll definitely comeback.
I am now not certain the place you’re getting your info, however great topic.
I must spend some time studying much more or understanding more.
Thanks for magnificent information I was in search of this info
for my mission.
Thank you for the good writeup. It in fact was a amusement account it.
Look advanced to far added agreeable from you!
However, how could we communicate?
Фирменный интернет-магазин Bottega Veneta предлагает разнообразие оригинальной продукции от итальянской марки. На сайте вы сможете выбрать и приобрести изделия из новых коллекций с доставкой по Москве и России.
https://bottega-official.ru
https://socialioapp.com/story3724130/Купить-fendi
Hello! I’ve been following your website for a long time now and finally got the
courage to go ahead and give you a shout out from Lubbock Tx!
Just wanted to mention keep up the great work!
Одежду и аксессуары модного дома Balenciaga можно приобрести в этом магазине. Широкий ассортимент моделей доступен для покупателей, ищущих стильные новинки. Ознакомьтесь с предложениями и найдите идеальный вариант прямо сейчас.
Одежда Balenciaga
На данной платформе вы можете приобрести изделия бренда знаменитого бренда Loro Piana. Представленный ассортимент включает эксклюзивные изделия, производимые с использованием природного сырья и современных технологий. Погрузитесь в атмосферу стиля и комфорта, который предлагает Loro Piana.
https://loropiana.whitezorro.ru
Hi, I do believe this is a great site. I stumbledupon it
😉 I’m going to return yet again since I book marked it.
Money and freedom is the best way to change, may you be
rich and continue to help others.
Бренд Balenciaga является одним из самых известных домов высокой моды, который появился в начале 20 века испанским дизайнером Кристобалем Баленсиагой. Он славится своими смелыми дизайнерскими решениями и необычными силуэтами, которые часто бросают вызов традиционным представлениям о моде.
https://balenciaga.whitesneaker.ru/
Patek Philippe is a legendary Swiss watchmaker celebrated for its high-quality watches. Founded in 1839, the brand continues to uphold its tradition of precision. Luxury watch fans seek out Patek Philippe for its innovations and exclusivity.
https://patek.superpodium.com
Бренд Баленсиага — это знаменитый парижский модный бренд, основывающийся своим инновационным подходом к моде. Созданный в 1919 году Кристобалем Баленсиагой, бренд стал культовым именем в мире моды. Сегодня Balenciaga славится своими уникальными изделиями, меняющими представление о стиле.
https://balenciaga.metamoda.ru
Your means of describing the whole thing in this paragraph is truly fastidious, every one
can easily be aware of it, Thanks a lot.
We are a gaggle of volunteers and starting a new scheme
in our community. Your web site offered us with valuable information to work on. You’ve performed an impressive
task and our entire community will probably be thankful to you.
Very nice post. I just stumbled upon your blog and wanted to say
that I have truly enjoyed browsing your blog posts.
After all I’ll be subscribing to your rss feed
and I hope you write again very soon!
When someone writes an paragraph he/she retains the plan of a user in his/her
mind that how a user can understand it. Therefore that’s why this article is perfect.
Thanks!
Hey! I just wanted to ask if you ever have any trouble with hackers?
My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no backup.
Do you have any methods to prevent hackers?
Hello would you mind stating which blog platform you’re working
with? I’m going to start my own blog in the near future but I’m having a
hard time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your design and style seems different then most blogs
and I’m looking for something completely unique.
P.S My apologies for getting off-topic but I had to ask!
Hi there, I enjoy reading all of your article. I like to write a little comment to support you.
Fantastic site. Lots of useful information here. I am sending it to some pals ans additionally
sharing in delicious. And certainly, thanks to your sweat!
You are so awesome! I do not think I have read anything like that before.
So great to find somebody with some unique thoughts on this subject matter.
Really.. many thanks for starting this up. This website
is something that is required on the internet, someone with a bit of originality!
This info is worth everyone’s attention. Where can I find
out more?
My brother suggested I might like this web site. He was totally right.
This publish actually made my day. You can not consider simply how a lot time I had spent for
this information! Thank you!