【发布时间】:2015-12-23 16:28:32
【问题描述】:
我已经减少了以下玩具代码的崩溃:
// DLLwithOMP.cpp : build into a dll *with* /openmp
#include <tchar.h>
extern "C"
{
__declspec(dllexport) void funcOMP()
{
#pragma omp parallel for
for (int i = 0; i < 100; i++)
_tprintf(_T("Please fondle my buttocks\n"));
}
}
_
// ConsoleApplication1.cpp : build into an executable *without* /openmp
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
typedef void(*tDllFunc) ();
int main()
{
HMODULE hDLL = LoadLibrary(_T("DLLwithOMP.dll"));
tDllFunc pDllFunc = (tDllFunc)GetProcAddress(hDLL, "funcOMP");
pDllFunc();
FreeLibrary(hDLL);
// At this point the omp runtime vcomp140[d].dll refcount is zero
// and windows unloads it, but the omp thread team remains active.
// A crash usually ensues.
return 0;
}
这是一个 MS 错误吗?是否有一些我错过的 OMP 线程清理 API(probably not,但也许)?我手头没有其他编译器。他们是否以不同的方式对待这种情况? (再次,probably not)OMP 标准对这种情况有什么要说的吗?
【问题讨论】:
-
在
Unloaded 'C:\Windows\SysWOW64\vcomp100d.dll'之后在VS2010 中尝试了您的代码,在return 0之后,我确实遇到了一些访问冲突。但是当注释掉FreeLibrary时,不会出现访问冲突。
标签: visual-c++ openmp msvcrt