Cannot get value from invalid enumeration

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
micksulley
Posts: 78
Joined: Fri May 11, 2018 9:28 am

Cannot get value from invalid enumeration

Post by micksulley »

OS: Linux Mint 18.3 Sylvia
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13959 (Git) AppImage
Build type: None
Branch: master
Hash: 2f18182b6dff87f8857787c854e39ca4d441f993
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedKingdom (en_GB)

I have a model, attached, which shows a pop up error box when I load it saying "Cannot get value from invalid enumeration". Nothing seems to be flagged as an error, how can I find out what is wrong?
Attachments
HoleTest4.fcstd
(35.61 KiB) Downloaded 26 times
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Cannot get value from invalid enumeration

Post by mlampert »

That error has been popping up erverywhere. I tracked it back to a commit but don't know what it is for
wmayer wrote:ping
any insights? Is there something Path is doing that causes this message?
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Cannot get value from invalid enumeration

Post by sliptonic »

I'm seeing this too and very predictably. It occurs whenever I add a job, even if there are no operations in the job. Save and reload causes the error.
I'm not sure how to debug this one.
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Cannot get value from invalid enumeration

Post by wmayer »

Please check if it still happens with the latest master.

The problem with the old implementation of PropertyEnumeration::getValueAsString was that in case of an invalid enumeration value (e.g. the index is out of range) a null pointer is returned which in most cases the calling instance doesn't check and assign it to a std::string. However, assigning a null pointer to a std::string is invalid and raises a segfault.

To avoid to change all places where getValueAsString is used without further checks and to avoid future problems the method now raises an exception.
Now there was (at least) one place where the exception wasn't handled and caused the document load to not finish properly. This should be fixed now with: git commit 9faa7fc5
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Cannot get value from invalid enumeration

Post by sliptonic »

I think that's got it.

I still see "Enumeration index -1 is out of range, ignore it" in the report view but not the error.
Post Reply