Levana_YG 2022-08-16 10:10 采纳率: 0%
浏览 59
已结题

opencascade库文件<Handle_Standard_Transient.hxx>出现0xC0000005: 读取位置 0x0000000000000050 时发生访问冲突

各位,前几天我尝试运行之前师兄的一个程序(基于opencascade做的一个虚拟装配程序),发现在运行过程中opencascade的一个库文件<Handle_Standard_Transient.hxx>时出现错误: 0xC0000005: 读取位置 0x0000000000000050 时发生访问冲突。头文件代码如下。报错位置为Handle(Standard_Transient) (const Handle(Standard_Transient)& aTid)
class Handle(Standard_Transient)

{
public:

// Public methods

//! Empty constructor
Handle(Standard_Transient) ()
: entity(0)
{
}

//! Constructor from pointer to new object指向新对象指针的构造函数
Handle(Standard_Transient) (const Standard_Transient anItem)
: entity ( (Standard_Transient
)anItem )
{
BeginScope();
}

//! Copy constructor拷贝构造函数
** Handle(Standard_Transient) (const Handle(Standard_Transient)& aTid)
: entity ( aTid.entity )
{
BeginScope();
} **

//! Destructor
~Handle(Standard_Transient)()
{
EndScope();
}

//! Assignment operator
Handle(Standard_Transient)& operator=(const Handle(Standard_Transient)& aHandle)
{
Assign(aHandle.Access());
return *this;
}

//! Assignment operator
Handle(Standard_Transient)& operator=(const Standard_Transient* anItem)
{
Assign(anItem);
return *this;
}

//! Nullify the handle
void Nullify()
{
EndScope();
}

//! Check for being null
Standard_Boolean IsNull() const
{
return entity == 0;
}

//! Returns pointer to referred object
Standard_Transient* Access()
{
return entity;
}

//! Returns const pointer to referred object
const Standard_Transient* Access() const
{
return entity;
}

//! Cast to pointer to referred object
operator Standard_Transient*()
{
return entity;
}

//! Cast to const pointer to referred object
operator const Standard_Transient*() const
{
return entity;
}

//! Member access operator (note non-const)
Standard_Transient* operator->() const
{
return entity;
}

//! Dereferencing operator
Standard_Transient& operator*()
{
return *entity;
}

//! Const dereferencing operator
const Standard_Transient& operator*() const
{
return *entity;
}

//! Check for equality
int operator==(const Handle(Standard_Transient)& right) const
{
return entity == right.entity;
}

//! Check for equality
int operator==(const Standard_Transient *right) const
{
return entity == right;
}

//! Check for equality
friend bool operator==(const Standard_Transient *left, const Handle(Standard_Transient)& right)
{
return left == right.entity;
}

//! Check for inequality
bool operator!=(const Handle(Standard_Transient)& right) const
{
return entity != right.entity;
}

//! Check for inequality
bool operator!=(const Standard_Transient *right) const
{
return entity != right;
}

//! Check for inequality
friend bool operator!=(const Standard_Transient *left, const Handle(Standard_Transient)& right)
{
return left != right.entity;
}

//! Down casting operator; dummy provided for consistency with other classes
//! (descendants)
static const Handle(Standard_Transient)& DownCast(const Handle(Standard_Transient)& AnObject)
{
return AnObject;
}

//! Dump pointer to a referred object to a stream
Standard_EXPORT void Dump(Standard_OStream& out) const;

protected:
// Protected methods for descendants

//! Returns non-const pointer to referred object
Standard_Transient* ControlAccess() const
{
return entity;
}

//! Assignment
Standard_EXPORT void Assign (const Standard_Transient *anItem);

private:
// Private methods

//! Increment reference counter of referred object
Standard_EXPORT void BeginScope();

//! Decrement reference counter and if 0, destroy referred object
Standard_EXPORT void EndScope();

public:

DEFINE_STANDARD_ALLOC

private:
// Field
Standard_Transient *entity;
};

//! Function in global scope to check handles for equality.函数在全局范围内检查句柄是否相等。
//! Will be used with standard OCCT collections like NCollection_DataMap within NCollection_DefaultHasher当没有为具体类型定义特化时,将与
//! when there are no specialization defined for concrete type. NCollection_DefaultHasher中的标准OCCT集合一起使用,如NCollection_DataMap。
//! Notice that this implementation compares only pointers to objects!注意,这个实现只比较指针和对象!
inline Standard_Boolean IsEqual (const Handle(Standard_Transient)& theFirst,
const Handle(Standard_Transient)& theSecond)
{
return theFirst == theSecond;
}

#ifdef _WIN32
#pragma warning (pop)
#endif

#endif

错误类型为0xC0000005: 读取位置 0x0000000000000050 时发生访问冲突
我的解答思路和尝试过的方法
求问各位有没有用opencascade时遇到类似的问题,遇到过类似的问题是怎么解决的呢?
  • 写回答

3条回答 默认 最新

  • ilmss 2022-08-16 10:58
    关注

    报错0xC0000005 : 读取位置 0x00000000 时发生访问冲突。
    上面的意思就是,你把值付给了不该赋给的变量,或者说你把值付给了不能付给的变量(或者常量)
    (1)最简单也最直接的错误可能就是scanf()的问题,我们都知道输入的时候都是scanf("%格式",&变量),那么除了字符串(可要&,可不要)之外,所有的输入都需要&,如果你丢了,在很多编译器上变异的时候是查不出来的,也就是说是没有错的,但是输入数据会差生上述错误,是因为写成scanf("%格式",变量)这种形式了,这样你所输入的变量就不知道会存储到哪里。
    (2)空指针赋值的问题。
    我们知道如果某一个指针是空的是不能直接给他赋值的,原因是空指针不知道指得什么东西,那么他没有固定的内存,现在你给他赋值,通俗点理解就是他不知道该怎么存,也不知道存在哪,也不会储存,但是现在你有需要让他存储,那么就会出现上述的问题,这时候解决办法就是重新申请空间(用malloc或者new),或者是你尽量避免他成为空指针,或者是当他有成为空指针的可能性时,你就单独讨论。

    大概率是出现了空指针。没有判断指针是否为空就进行后续操作导致的错误

    评论

报告相同问题?

问题事件

  • 系统已结题 8月24日
  • 创建了问题 8月16日

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题