(调试CRT)C ++ 17释放调用错误免费? [英] (Debug CRT)C++17 Deallocation Calling Wrong Free?

查看:49
本文介绍了(调试CRT)C ++ 17释放调用错误免费?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!


所以最近我一直在努力使用C ++ 17标准运行应用程序。其中一个项目是一个DLL,它使用一些包装类来分配一些线程。它们是Win32线程,而不是STL线程。


应用程序的调试版本具有覆盖new,malloc等的自定义alloc和dealloc函数,它们也使用CRT调试库,这是有用的用于追踪泄漏等。如果我将DLL项目切换到C ++ 14,调试
版本运行完全正常,它似乎在线程包装类上调用delete时进行适当的释放。


但是,如果我将其切换到C ++ 17,而不是执行标准的免费操作,它会尝试执行对齐的自由和崩溃。


发布版本没有此问题,这个问题似乎只存在于这个关于线程的DLL中,并且只存在于C ++ 17中。


代码基本上是这样的:



SomeThreadClass * pMyThread = new SomeThreadClass;



和deallocation



删除pMyThread;



显然它还有更多,但是就分配和解除分配而言,这就是它的全部内容。



当我为C ++ 14设置项目时,似乎根据"外部守则"堆栈跟踪它似乎调用了一些CRT自由函数,而使用C ++ 17它似乎显示标量删除函数,看起来像:


delete(void * block,std) :: align_val_t __formal)第32行


不幸的是,我无法真正共享任何实际的代码,但是从C ++ 14切换到C ++时会发生一些奇怪的事情。 17。



我正在使用带有Windows SDK版本7.0的v141_xp工具集运行Visual Studio 2017。



工作与不工作的唯一区别是C ++语言标准。



关于发生了什么的任何想法?


解决方案

>不幸的是,我无法真正分享任何实际代码


你能分享一个重现问题的最小项目吗?


Dave


通过社区论坛NNTP服务器1.1.55.0"

Hello there!

So recently I'd been working to make an application run with the C++17 standard. One of the projects is a DLL which in it allocates some threads using some wrapper classes. They're Win32 threads, not STL threads.

The debug build of the application has custom alloc and dealloc functions overriding new, malloc, and such which also uses the CRT debug library which is useful for tracking down leaks and such. If I switch the the DLL project to C++14, the debug version runs totally fine, it seems to do proper deallocation when delete is called on the thread wrapper class.

However, if I switch it to C++17, instead doing a standard free operation, it tries to do an aligned free and crashes.

The release build does not have this problem, and this issue seems to only exist in this one DLL regarding threads, and only with C++17.

The code is basically this:

SomeThreadClass *pMyThread = new SomeThreadClass;

and for deallocation

delete pMyThread;

Obviously there's more to it than that, but as far as allocation and deallocation, this is all there is to it.

When I have the project set for C++14, it seems under the "External Code" of the stack trace it seems to call some CRT free function, whereas with C++17 it seems to show scalar delete functions, something that looks like:

delete(void * block, std::align_val_t __formal) Line 32

Unfortunately, I can't really share any actual code, but there is something weird that is going on when switching from C++14 to C++17.

I'm running Visual Studio 2017 with the v141_xp toolset with Windows SDK version 7.0.

The only difference between it working and not working is the C++ language standard.

Any ideas as to what's going on?

解决方案

>Unfortunately, I can't really share any actual code

Can you share a minimal project that reproduces the issue?

Dave


这篇关于(调试CRT)C ++ 17释放调用错误免费?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆