For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

[PATCH] Fix segfault in HashCode() (subtitle: implicit conversions considered harmful)

Denis Barbier's picture
Forums: 

Hello,

The code below segfaults on Linux when MMGT_OPT is set to 0 or 2:

#include
#include

int main(int argc, char **argv) {
Standard_Transient s;
Standard_Integer i = s.HashCode(1000);
std::cout return 0;
}

The current implementation calls HashCode(Handle_Standard_Transient,Standard_Integer)
due to implicit conversion operator. But if object is allocated on the stack,
a segmentation fault occurs when the Handle_Standard_Transient temporary object
is deleted. This happens if MMGT_OPT is set and different from 1.

Implicit conversions should really be forbidden in order to avoid those subtle bugs.

Attachments: 
Forum supervisor's picture

Dear Denis,
The reported problem is checked and reproduced.
The corresponding issue with ID = 22749 has been registered.
Later you can know if the issue is resolved by checking references to the specified ID in OCCT Release Notes. The analysis of the issue will take some time depending on our technical capability and availability of resources.
Thanks for your contribution.
Regards