Cannot get value from invalid enumeration

Here's the place for discussion related to CAM/CNC and the development of the Path module.
micksulley
Posts: 78
Joined: Fri May 11, 2018 9:28 am

Cannot get value from invalid enumeration

Postby micksulley » Wed Jul 04, 2018 10:20 pm

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 6 times
mlampert
Posts: 1436
Joined: Fri Sep 16, 2016 9:28 pm

Re: Cannot get value from invalid enumeration

Postby mlampert » Thu Jul 05, 2018 12:44 am

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
Posts: 1598
Joined: Tue Oct 25, 2011 10:46 pm

Re: Cannot get value from invalid enumeration

Postby sliptonic » Tue Aug 07, 2018 3:00 pm

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
Site Admin
Posts: 15123
Joined: Thu Feb 19, 2009 10:32 am

Re: Cannot get value from invalid enumeration

Postby wmayer » Tue Aug 07, 2018 3:18 pm

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
Posts: 1598
Joined: Tue Oct 25, 2011 10:46 pm

Re: Cannot get value from invalid enumeration

Postby sliptonic » Tue Aug 07, 2018 5:53 pm

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.