[Spice-devel] [spice-gtk] Fix using NULL main channel reference

Victor Toso victortoso at redhat.com
Wed Sep 19 13:30:54 UTC 2018


Hi,

On Mon, Aug 13, 2018 at 01:44:37PM +0200, Javier Celaya wrote:
> Hi, sorry for the late response, I was on holidays
> El mar, 24-07-2018 a las 17:58 +0200, Marc-André Lureau escribió:
> > On Mon, Jul 16, 2018 at 6:45 PM, Javier Celaya<javier.celaya at flexvdi.
> > com> wrote:The main channel reference d->main of SpiceWidget is
> > initialized onconstruction. However, it is used a couple of times
> > before that momentwhile setting the default values of some
> > properties, like resize-guest.This results in some annoying critical
> > log messages. This commit makessure that d->main is not used in such
> > situations if it is NULL.
> > Could you provide a reproducer of such warnings? I don't remember
> > seeing one.
> 
> I see them each time I connect to a Spice session with spicy. Follow
> me:
> - These warnings appear because d->main is NULL.
> - d->main is set in spice-widget.c:channel_new function, when
> the new channel is the main channel.
> - channel_new is called from spice_display_constructed with the
> list of channels that already exist; obviously, the main
> channel is one of them.
> - There are SpiceDisplay properties that are set during
> construction, before spice_display_constructed is called, that
> trigger the code I am fixing with this patch.

Makes sense.

> For instance, after setting "resize-guest" to its default value
> TRUE, update_ready is called.So I do not see how you are not
> seeing these warnings. It does not seem to be a race condition,
> it happens always.

resize-guest-enable's default is FALSE so
spice_main_channel_update_display_enabled() would not be called
and not sure how you are manage to trigger it?

I've added a g_warn_if_fail(d->main != NULL); and indeed the
d->main can be null at that point, so I'm keen to take the patch
although a different solution might be better...

Could you send a v2 with d->main check against NULL as Frediano
mentioned and add the critical you see on commit log for
completeness ?

Sorry for delay, so many patches!
Victor

> > --- src/spice-widget.c | 4 ++-- 1 file changed, 2 insertions(+), 2
> > deletions(-)
> > diff --git a/src/spice-widget.c b/src/spice-widget.cindex
> > 72f5334..5187b0c 100644--- a/src/spice-widget.c+++ b/src/spice-
> > widget.c@@ -255,7 +255,7 @@ static void update_ready(SpiceDisplay
> > *display)      * state here. If 'resize-guest' is false, we can
> > assume that the      * application will manage the state of the
> > displays.      */-    if (d->resize_guest_enable) {+    if (d-
> > >resize_guest_enable && d->main)
> > {         spice_main_channel_update_display_enabled(d->main,
> > get_display_id(display), ready, TRUE);     }
> > @@ -1247,7 +1247,7 @@ static void recalc_geometry(GtkWidget
> > *widget)                   d->area.width, d-
> > >area.height,                   d->ww, d->wh, zoom);
> > -    if (d->resize_guest_enable)+    if (d->resize_guest_enable && d-
> > >main)         spice_main_channel_update_display(d->main,
> > get_display_id(display),                                           d-
> > >area.x, d->area.y, d->ww / zoom, d->wh / zoom, TRUE);
> > It looks like this may not give you the desired display size.
> 
> Again, the warning happens when the property "scaling" is set during
> SpiceDisplay construction, which calls scaling_update. You cannot call
> spice_main_channel_update_display with d->main == NULL, so this check
> is harmless.
> >  }--2.17.0
> > _______________________________________________Spice-devel mailing
> > listSpice-devel at lists.freedesktop.orghttps://lists.freedesktop.org/ma
> > ilman/listinfo/spice-devel
> > 
> > 
> > 
> -- 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> 
>               
>               
>           
>           
>             Javier Celaya Alastrué
>           
>            Chief Technology Officer
>       
>       
>         
>            
>         javier.celaya at flexvdi.com
>         
>         
>           
>         +34696969959 
>       
>           
>         j_celaya
>         
>         
>           
>         Legal Information and Privacy Policy
>           
>       
>     
>     
>         
>             Política de confidencialidad
>             Este mensaje y los ficheros anexos son confidenciales dirigiéndose exclusivamente al destinatario mencionado en el encabezamiento. Si usted ha recibido este correo por error, tenga la amabilidad de eliminarlo de su sistema y no divulgar el contenido a terceros. Los datos personales facilitados por usted o por terceros serán tratados por FLEXIBLE SOFTWARE SOLUTIONS S.L.U. con la finalidad de gestionar y mantener los contactos y relaciones que se produzcan como consecuencia de la relación que mantiene con FLEXIBLE SOFTWARE SOLUTIONS S.L.U. Normalmente, la base jurídica que legitima este tratamiento, será su consentimiento, el interés legítimo o la necesidad para gestionar una relación contractual o similar. El plazo de conservación de sus datos vendrá determinado por la relación que mantiene con nosotros. Para más información al respecto, o para ejercer sus derechos de acceso, rectificación, supresión, oposición, limitación o portabilidad, dirija una comunicación por escrito a FLEXIBLE SOFTWARE SOLUTIONS S.L.U: Avenida de Ranillas 1D, Planta 3, Oficina 3G, Zaragoza o al correo electrónico pdo at flexvdi.com. En caso de considerar vulnerado su derecho a la protección de datos personales, podrá interponer una reclamación ante la Agencia Española de Protección de Datos (www.agpd.es). 
>         
>     

> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180919/045db1db/attachment.sig>


More information about the Spice-devel mailing list