Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1420706

Summary: DisplayChannel monitors property is not usable in python
Product: Red Hat Enterprise Linux 7 Reporter: Pavel Hrdina <phrdina>
Component: pygobject3Assignee: Matthew Barnes <mbarnes>
Status: CLOSED WONTFIX QA Contact: Desktop QE <desktop-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: Cameronsplaze222, cfergeau, jsuchane, phrdina
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-25 14:59:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1339289    

Description Pavel Hrdina 2017-02-09 10:56:45 UTC
The "monitors" property is implemented as G_TYPE_ARRAY which is internally implemented as GArray of SpiceDisplayMonitorConfig.  Because the "monitors" property is defined as generic G_TYPE_ARRAY the pygobject doesn't know how to convert it to python and any usage of "monitors" property in python code prints this error message:

  CRITICAL **: Stack overflow protection. Can't copy array element into GIArgument.

The python code simply tries to get the property:

  ...
  monitors = displayChannel.get_property("monitors").
  ...


This blocks Bug 1339289 that requests to implement multi-monitor support into virt-maanger.

To solve this issue spice-gtk needs to add for example a new property that would be possible to use in python or introduce getter method/function that would return DisplayMonitorConfig for specific monitor based on index.

Comment 2 Christophe Fergeau 2017-02-09 13:56:08 UTC
Wouldn't it be enough to add an annotation to specify the type contained in the GArray ?

diff --git a/src/channel-display.c b/src/channel-display.c
index ca56cd1..0d025d0 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -284,7 +284,7 @@ static void spice_display_channel_class_init(SpiceDisplayChannelClass *klass)
                            G_PARAM_STATIC_STRINGS));

     /**
-     * SpiceDisplayChannel:monitors:
+     * SpiceDisplayChannel:monitors: (type GArray(SpiceDisplayMonitorConfig))
      *
      * Current monitors configuration.
      *


I can provide a scratch build if needed

Comment 3 Pavel Hrdina 2017-02-09 14:19:21 UTC
I've just tested it and it's not enough.  The thing is that the property is defined as G_TYPE_ARRAY and that's it.  Pygobject doesn't know how to what the type of items inside the array is so it tries to use a generic type and fails.

For example, "gl-scanout" is represented as single custom type and it works, because that type is described and it's possible to map it to some python objects.

Another example is builtin G_TYPE_STRV which is an array of strings and it works as well.

It might by pygobject bug or just limitation of what it can handle.  If you use the property in C code like virt-viewer does, you can simply get a pointer and type cast it to correct one, but I'm afraid that this is not an option for pygobject.

Comment 4 Christophe Fergeau 2017-02-09 14:30:15 UTC
(In reply to Pavel Hrdina from comment #3)
> I've just tested it and it's not enough.  The thing is that the property is
> defined as G_TYPE_ARRAY and that's it.  Pygobject doesn't know how to what
> the type of items inside the array is so it tries to use a generic type and
> fails. 

No, the property is not just defined as G_TYPE_ARRAY with the annotation. Before the change, /usr/share/gir-1.0/SpiceClientGLib-2.0.gir only describes the "monitors" property as:
      <property name="monitors" version="0.13" transfer-ownership="none">
        <doc xml:space="preserve">Current monitors configuration.</doc>
        <array name="GLib.Array">
          <type name="gpointer" c:type="gpointer"/>
        </array>
      </property>
so I agree that it's not possible for python to know its content.

However, after regenerating SpiceCLientGlib-2.0.gir with the change I suggested, the .gir content becomes:
      <property name="monitors" version="0.13" transfer-ownership="none">
        <doc xml:space="preserve">Current monitors configuration.</doc>
        <array name="GLib.Array">
          <type name="DisplayMonitorConfig"/>
        </array>
      </property>
so this time the type of the elements in the array is known.
I would expect that this is enough information for the python gobject-introspection layer to do the right thing and let you access the array content.

Comment 5 Pavel Hrdina 2017-02-09 14:55:18 UTC
I've built spice-gtk with that patch and it's not enough to make it work in python.  Still the same error.

Comment 6 Pavel Grunt 2017-02-10 09:34:03 UTC
I agree with the comment 4, moving to pygobject for investigation.

I searched little bit and found https://mail.gnome.org/archives/python-hackers-list/2015-February/msg00000.html so we are not the only one having the issue

Comment 7 Christophe Fergeau 2017-02-10 09:41:33 UTC
(executive summary, pygobject currently does not support array of structs, just arrays of pointers to struct)