Winapi x64和Win32配置之间的访问位置0xFFFFFFFFF崩溃
我写这封信是因为我在代码中使用的库的DLL有问题。我已经寻找过类似的线程,它们与发布模式下的崩溃相关,但与调试模式无关,但它们似乎并不完全适合我所面临的问题。我准备了一个小例子来说明这个问题。我正在使用VisualStudio2010编译我的示例以及开放级联库 问题是,当我在版本x64配置中编译和运行我的示例时,创建BRepOffsetAPI_MakePipe对象会导致应用程序崩溃,因为访问读取位置0xFFFFFFFF导致TKBRep.dll崩溃。还有一点让人费解的是,如果代码是在Win32版本中编译的,那么一切都正常,结果也正确。此后,我将描述编译库的过程和我编写的代码。请注意,我创建的对象(即圆柱体、面)是使用OCC类创建的。我目前使用的是6.8.0版,但我发现6.9.0版也存在同样的问题。因此,我倾向于认为问题出在我正在编写的代码中 为Win32和x64配置安装OCC的过程Winapi x64和Win32配置之间的访问位置0xFFFFFFFFF崩溃,winapi,visual-studio-2013,64-bit,release,Winapi,Visual Studio 2013,64 Bit,Release,我写这封信是因为我在代码中使用的库的DLL有问题。我已经寻找过类似的线程,它们与发布模式下的崩溃相关,但与调试模式无关,但它们似乎并不完全适合我所面临的问题。我准备了一个小例子来说明这个问题。我正在使用VisualStudio2010编译我的示例以及开放级联库 问题是,当我在版本x64配置中编译和运行我的示例时,创建BRepOffsetAPI_MakePipe对象会导致应用程序崩溃,因为访问读取位置0xFFFFFFFF导致TKBRep.dll崩溃。还有一点让人费解的是,如果代码是在Win32版本
void constructWires(gp_Pnt pointZero, gp_Pnt pointOne,
TopoDS_Wire& circular, TopoDS_Wire& straight,
TopoDS_Face& faceCircular)
{
BRepBuilderAPI_MakeEdge edgeS(pointZero, pointOne);
edgeS.Build(); edgeS.Check();
BRepBuilderAPI_MakeWire wireS(edgeS.Edge());
wireS.Build(); wireS.Check();
straight = wireS.Wire();
gp_Vec vec(pointZero.X() - pointOne.X(), pointZero.Y() - pointOne.Y(), pointZero.Z() - pointOne.Z());
gp_Dir dir = vec.Normalized();
gp_Ax2 ax(pointZero, dir);
Handle(Geom_Circle) circle = new Geom_Circle(ax, 50.0);
BRepBuilderAPI_MakeEdge edgeC(circle);
edgeC.Build(); edgeC.Check();
BRepBuilderAPI_MakeWire wireC(edgeC.Edge());
wireC.Build(); wireC.Check();
circular = wireC.Wire();
// Face One creation
gp_Pln plane(pointZero, dir);
BRepBuilderAPI_MakeFace faceCreated(plane, circular, Standard_True);
faceCreated.Build(); faceCreated.Check();
faceCircular = faceCreated.Face();
}
void buildSolid(TopoDS_Wire& circ, TopoDS_Wire& straight, TopoDS_Solid& solid, TopoDS_Face faceToSweep)
{
//BRepTools::Write(straight, "straight.brep");
//BRepTools::Write(circ, "circ.brep");
// In this example, the shape is a cylinder but the class
// BRepOffsetAPI_MakePipe because the wire representing the
// axis of the cylinder might be composed of different edges
// properly alinged.
// This line generates the TKBRep.dll failure trying to access
// 0xFFFFFFFFFF location.
BRepOffsetAPI_MakePipe shell(straight, faceToSweep);
shell.Build();
shell.Check();
//shell.MakeSolid();
TopExp_Explorer solidInS(shell.Shape(), TopAbs_SOLID);
if (!solidInS.More())
{
std::cout << "Error when creating solid!" << std::endl;
return;
}
solid = TopoDS::Solid( solidInS.Current() ) ;
BRepTools::Write(solid, "solid.brep");
}
void cutFace(TopoDS_Shape solid, TopoDS_Shape face, TopoDS_Shape& shape)
{
BRepTools::Write(face, "faceInCut.brep");
BRepTools::Write(solid, "solidInCut.brep");
TopoDS_Shape faceToCut(face);
TopoDS_Shape solidToCut(solid);
BRepAlgoAPI_Cut cut(faceToCut, solidToCut);
cut.Build(); cut.Check();
shape = cut.Shape();
}
TopoDS_Face constructSquareFace()
{
gp_Pnt pOne(-100.0, 75.0, 0.0);
gp_Pnt pTwo(-100.0, -75.0, 0.0);
gp_Pnt pThree(200.0, -75.0, 0.0);
gp_Pnt pFour(200.0, 75.0, 0.0);
BRepBuilderAPI_MakeEdge edgeOne(pOne, pTwo);
BRepBuilderAPI_MakeEdge edgeTwo(pTwo, pThree);
BRepBuilderAPI_MakeEdge edgeThree(pThree, pFour);
BRepBuilderAPI_MakeEdge edgeFour(pFour, pOne);
BRepBuilderAPI_MakeWire wire(edgeOne.Edge(), edgeTwo.Edge(), edgeThree.Edge(), edgeFour.Edge());
wire.Build(); wire.Check();
BRepBuilderAPI_MakeFace sqFace(wire.Wire(), Standard_True);
sqFace.Build(); sqFace.Check();
return sqFace.Face();
}
void testCrash(void)
{
gp_Pnt pointZero(0.0, 0.0, 0.0);
gp_Pnt pointOne(100.0, 0.0, 0.0);
TopoDS_Wire circular;
TopoDS_Wire straight;
TopoDS_Face faceCircular;
// This method creates a circular face which then will be swept
// along the straight wire which represents the axis of the cylinder.
constructWires(pointZero, pointOne, circular, straight, faceCircular);
TopoDS_Solid solid;
// This method constructs the solid, i.e. cylinder, used to cut.
buildSolid(circular, straight, solid, faceCircular);
BRepTools::Write(solid, "solid.brep");
// This is the face which will be cut.
TopoDS_Face faceToCut = constructSquareFace();
BRepTools::Write(faceToCut, "sqFace.brep");
// Perform cut operation.
TopoDS_Shape shape;
cutFace(solid, faceToCut, shape);
BRepTools::Write(shape, "shape.brep");
std::cout << "Done!!" << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Started" << std::endl;
testCrash();
std::cout << "Finished" << std::endl;
return 0;
}
void构造函数(gp_Pnt pointZero,gp_Pnt pointOne,
地形线和圆形,地形线和直线,
地形(面和面圆形)
{
BRepBuilderAPI_MakeEdge边(点零,点一);
edgeS.Build();edgeS.Check();
BRepBuilderAPI_MakeWire电线(edgeS.Edge());
wireS.Build();wireS.Check();
直线=导线。导线();
gp_Vec Vec(pointZero.X()-pointOne.X(),pointZero.Y()-pointOne.Y(),pointZero.Z()-pointOne.Z());
gp_Dir=vec.Normalized();
总成Ax2 ax(点零,方向);
手柄(几何圆)圆=新几何圆(ax,50.0);
BRepBuilderAPI_MakeEdge edgeC(圆);
edgeC.Build();edgeC.Check();
BRepBuilderAPI_MakeWire wireC(edgeC.Edge());
wireC.Build();wireC.Check();
圆形=wireC.Wire();
//面对一个创造
总平面图(零点,方向);
BRepBuilderAPI_MakeFace已创建(平面、圆形、标准_真);
faceCreated.Build();faceCreated.Check();
faceCircular=faceCreated.Face();
}
void buildSolid(拓扑线和圆环、拓扑线和直线、拓扑线和实体、拓扑面和面)
{
//BRepTools::Write(笔直,“stright.brep”);
//BRepTools::Write(circ,“circ.brep”);
//在本例中,形状是圆柱体,但类
//BRepOffsetAPI_MakePipe,因为表示
//圆柱体的轴可能由不同的边组成
//正确对齐。
//此行生成TKBRep.dll尝试访问时失败
//0xFFFFFFFF位置。
BRepOffsetAPI_MakePipe外壳(直管、小面排水管);
shell.Build();
shell.Check();
//shell.MakeSolid();
TopExp_Explorer solidInS(shell.Shape(),TopAbs_SOLID);
如果(!solidInS.More())
{
std::cout我已经了解是什么触发了我的小型应用程序崩溃。这与我如何编译OpenCasCade库有关。由于我正在为64位应用程序开发OCC代码,现在我将参考OCC的最新版本,即OCC 6.9.0,它(至少适用于Windows)其结果针对版本x64配置进行了测试和认证。但是,正如我所说,我在版本6.8.0 x64中看到了相同的问题。那时可能有一个独特的修复程序
安装OCC 6.9.0后,将创建win64文件夹bin和lib,其中包含在发布模式下编译的DLL和库。如果我的示例链接到这些文件,则不会崩溃,结果是正确的
现在让我们假设一个用户想要自己构建库。我要做的是:
-打开一个命令提示符窗口并转到C:\OpenCASCADE6.9.0\opencascade-6.9.0\文件夹。
-执行custom.bat和msvc.bat vc10调试win64
这将打开VC2010,可以选择生成配置。在解决方案资源管理器中,可以选择生成某些项目。例如,在我的项目中,我对生成除Draw文件夹中的项目外的所有项目感兴趣。我以调试模式生成项目,并执行示例,将其与新的DLL和Libs文件链接(现在分别分组在win64\vc10\bind和\libd中)。在调试模式下,正如我前面所说,它可以正常工作。另一方面,当相同的项目在发布模式下构建并且应用程序被执行时,它会崩溃
我出错的原因是,当我手工在发布模式下编译代码时,以及当我从安装中获得发布DLL和LIB时,生成设置不同
目前,我将依赖已安装的DLL和LIB。如果我有更多详细信息,我将在这里发布它们
问候
请注意,很抱歉提供了所有详细信息。我知道大多数细节对你们中的许多人来说都是显而易见的。问题在于我的Visual Studio 2010。正如发行说明中正确指出的,为了正确编译库,需要VS2010的SP1。这是我在VS2010中缺少的。我现在已经安装了VS2010的SP1,并测试了我的应用程序和应用程序它很好用
亲切问候,,
Paolo在访问冲突发生时,您是否检查了调试器中的调用堆栈?由于这是在发布配置中发生的,您可能希望使用编译器开关编译OCC二进制文件。唯一突出的是,TopoDS\u Face faceToSweep
是唯一未通过引用传递给的参数ode>buildSolid
函数-可能是doi的复制构造函数