Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumeration feature infinite loop due to availability condition #678

Closed
carLagoF opened this issue Jun 1, 2022 · 2 comments · Fixed by #689
Closed

Enumeration feature infinite loop due to availability condition #678

carLagoF opened this issue Jun 1, 2022 · 2 comments · Fixed by #689
Labels
1. bug Problems, incorrect behavior or appearance 5. Genicam Issue in Genicam implementation

Comments

@carLagoF
Copy link

carLagoF commented Jun 1, 2022

Hello!
I am trying to use aravis to get and set features from a camera. The issue is aravis enters an infinite loop when trying to get or set a couple of features of type enumeration. You can find below the call stack for the loop.

#4222 0x00007ffff78a2fe6 in _get_int_value (enumeration=0x5555556c9530, error=0x7fffff846068) at ../src/arvgcenumeration.c:339
#4223 0x00007ffff78a3c70 in arv_gc_enumeration_get_integer_value (gc_integer=0x5555556c9530, error=0x7fffff846068) at ../src/arvgcenumeration.c:634
#4224 0x00007ffff78b3df6 in arv_gc_integer_get_value (gc_integer=0x5555556c9530, error=0x7fffff846068) at ../src/arvgcinteger.c:50
#4225 0x00007ffff78aee10 in _update_variables (self=0x555555b0a270, error=0x7fffff8460f8) at ../src/arvgcswissknife.c:200
#4226 0x00007ffff78aefd4 in arv_gc_swiss_knife_get_integer_value (self=0x555555b0a270, error=0x7fffff8461a8) at ../src/arvgcswissknife.c:237
#4227 0x00007ffff78afb34 in arv_gc_int_swiss_knife_node_get_integer_value (self=0x555555b0a270, error=0x7fffff8461a8) at ../src/arvgcintswissknifenode.c:45
#4228 0x00007ffff78b3df6 in arv_gc_integer_get_value (gc_integer=0x555555b0a270, error=0x7fffff8461a8) at ../src/arvgcinteger.c:50
#4229 0x00007ffff789bacb in arv_gc_property_node_get_int64 (node=0x5555557008b0, error=0x7fffff8461a8) at ../src/arvgcpropertynode.c:380
#4230 0x00007ffff789f275 in arv_gc_feature_node_is_available (gc_feature_node=0x5555556f6ea0, error=0x7fffff846200) at ../src/arvgcfeaturenode.c:344
#4231 0x00007ffff78a28ed in arv_gc_enumeration_dup_available_int_values (enumeration=0x5555556c9610, n_values=0x7fffff846264, error=0x7fffff846270) at ../src/arvgcenumeration.c:142
#4232 0x00007ffff78a2fe6 in _get_int_value (enumeration=0x5555556c9610, error=0x7fffff846318) at ../src/arvgcenumeration.c:339

After some debugging I have downloaded the camera xml and found that this is happening due to two enumeration feature's pIsAvailable depending from one another. Looking at these conditions, they are mutually exclusive, so this doesn't seem to be a bad implementation of the xml (you can find below these features and their entries' availability conditions).

		<Enumeration Name="PixelFormat" NameSpace="Standard">
			<ToolTip>Format of the pixel to use for acquisition.</ToolTip>
			<Description>Format of the pixel to use for acquisition. It represents
        all the information provided by PixelCoding, PixelSize,
        PixelColorFilter but combined in one single value.</Description>
			<DisplayName>Pixel Format</DisplayName>
			<Visibility>Beginner</Visibility>
			<pIsLocked>TLParamsLocked</pIsLocked>
			<Streamable>Yes</Streamable>
			<EnumEntry Name="Mono8" NameSpace="Standard">
				<ToolTip>Mono 8 bit.</ToolTip>
				<Description>Mono 8 bit.</Description>
				<Value>17301505</Value>
			</EnumEntry>
			<EnumEntry Name="Mono10" NameSpace="Standard">
				<ToolTip>Mono 10 bit.</ToolTip>
				<Description>Mono 10 bit.</Description>
				<pIsAvailable>PixelFormatMono10AvailExpr</pIsAvailable>
				<Value>17825795</Value>
			</EnumEntry>
			<EnumEntry Name="Mono10Packed" NameSpace="Standard">
				<ToolTip>Mono 10 bit packed.</ToolTip>
				<Description>Mono 10 bit packed.</Description>
				<Value>17563652</Value>
			</EnumEntry>
			<EnumEntry Name="Mono12" NameSpace="Standard">
				<ToolTip>Mono 12 bit.</ToolTip>
				<Description>Mono 12 bit.</Description>
				<pIsAvailable>PixelFormatMono12AvailExpr</pIsAvailable>
				<Value>17825797</Value>
			</EnumEntry>
			<EnumEntry Name="Mono12Packed" NameSpace="Standard">
				<ToolTip>Mono 12 bit packed.</ToolTip>
				<Description>Mono 12 bit packed.</Description>
				<Value>17563654</Value>
			</EnumEntry>
			<EnumEntry Name="Mono16" NameSpace="Standard">
				<ToolTip>Mono 16 bit.</ToolTip>
				<Description>Mono 16 bit.</Description>
				<pIsAvailable>PixelFormatMono16AvailExpr</pIsAvailable>
				<Value>17825799</Value>
			</EnumEntry>
			<pValue>PixelFormatReg</pValue>
		</Enumeration>
[...]
		</Enumeration>
		<Enumeration Name="ImageSensorSelector" NameSpace="Standard">
			<ToolTip>Selection of image sensors that are readout.</ToolTip>
			<Description>Selection of image sensors that are readout.</Description>
			<DisplayName>Image Sensor Selector</DisplayName>
			<Visibility>Beginner</Visibility>
			<pIsLocked>TLParamsLocked</pIsLocked>
			<Streamable>Yes</Streamable>
			<EnumEntry Name="VIS0" NameSpace="Standard">
				<ToolTip>Visible sensor only.</ToolTip>
				<Description>Visible sensor only.</Description>
				<Value>1</Value>
			</EnumEntry>
			<EnumEntry Name="SWIR0" NameSpace="Standard">
				<ToolTip>SWIR sensor only.</ToolTip>
				<Description>SWIR sensor only.</Description>
				<Value>2</Value>
			</EnumEntry>
			<EnumEntry Name="All" NameSpace="Standard">
				<ToolTip>VIS and SWIR sensor.</ToolTip>
				<Description>VIS and SWIR sensor.</Description>
				<pIsAvailable>ImageSensorSelectorAllAvailExpr</pIsAvailable>
				<Value>3</Value>
			</EnumEntry>
			<pValue>ImageSensorSelectorReg</pValue>
		</Enumeration>
[...]
		<IntSwissKnife Name="PixelFormatMono10AvailExpr">
			<pVariable Name="VAR_IMAGESENSORSELECTOR">ImageSensorSelector</pVariable>
			<Formula> VAR_IMAGESENSORSELECTOR &lt;&gt; 3 </Formula>
		</IntSwissKnife>
		<IntSwissKnife Name="PixelFormatMono12AvailExpr">
			<pVariable Name="VAR_IMAGESENSORSELECTOR">ImageSensorSelector</pVariable>
			<Formula> VAR_IMAGESENSORSELECTOR &lt;&gt; 3 </Formula>
		</IntSwissKnife>
		<IntSwissKnife Name="PixelFormatMono16AvailExpr">
			<pVariable Name="VAR_IMAGESENSORSELECTOR">ImageSensorSelector</pVariable>
			<Formula> VAR_IMAGESENSORSELECTOR &lt;&gt; 3 </Formula>
		<IntSwissKnife Name="ImageSensorSelectorAllAvailExpr">
			<pVariable Name="VAR_PIXELFORMAT">PixelFormat</pVariable>
			<Formula> VAR_PIXELFORMAT &lt; 17825795 </Formula>

Looking at the code in aravis, this infinite loop seems to be happening because when one enumeration feature is being read, it searches for the possible int values the enumeration can take and their availability (in arv_gc_enumeration_dup_available_int_value). Then, as the availability of these values depends on the other enumeration feature, aravis tries to update its current value by reading the feature, which in turns searchs for the availability of its possible value which depend on the original feature we want to read.

I see some potential solutions regarding this issue. One solution would be to not check the possible values as aravis reads an enumeration or to not check availability of these and just retrieve all the defined values (for which a new function would be needed) or maybe it could be blamed just in a bad implementation of genicam by the camera manufacturer.

Camera description:

  • Interface GigE

Platform description:

  • Aravis version 0.8
  • OS: Ubuntu 20.04
  • Hardware: x86_64

Thank you in advance,
Carlos

@EmmanuelP EmmanuelP added 1. bug Problems, incorrect behavior or appearance 5. Genicam Issue in Genicam implementation labels Jul 7, 2022
EmmanuelP added a commit that referenced this issue Jul 7, 2022
Fixes #678

Removing this check, we will not know anymore if the value returned by the
device is a valid one. But it is the device fault, as on write the availability
is still checked.

And know we avoid an infinite loop on some devices like the one in the issue
report.
@EmmanuelP
Copy link
Contributor

Please try #689

@carLagoF
Copy link
Author

Yes, This should work just fine, thank you very much.

EmmanuelP added a commit that referenced this issue Jul 12, 2022
Fixes #678

Removing this check, we will not know anymore if the value returned by the
device is a valid one. But it is the device fault, as on write the availability
is still checked.

And know we avoid an infinite loop on some devices like the one in the issue
report.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. bug Problems, incorrect behavior or appearance 5. Genicam Issue in Genicam implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants