! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Handles returned by the Queue DBus method start from zero
Status:
RESOLVED: FIXED
Product:
Tumbler
Component:
General

Comments

Description afdw 2020-05-08 01:06:12 CEST
Handles are generated by the `tumbler_scheduler_request_new` function. Here is the current code ( https://gitlab.xfce.org/xfce/tumbler/-/blob/3520322eb453ee1349b14b080a0f7d23e4040b16/tumblerd/tumbler-scheduler.c#L264 ):
> TumblerSchedulerRequest *
> tumbler_scheduler_request_new (TumblerFileInfo    **infos,
>                                TumblerThumbnailer **thumbnailers,
>                                guint                length,
>                                const gchar         *origin)
> {
>   TumblerSchedulerRequest *request = NULL;
>   static gint              handle  = 0;
>   guint                    n;
> 
>   g_return_val_if_fail (infos != NULL, NULL);
>   g_return_val_if_fail (thumbnailers != NULL, NULL);
> 
>   request = g_new0 (TumblerSchedulerRequest, 1);
>   if (origin)
>     request->origin = g_strdup (origin);
>   request->dequeued = FALSE;
>   request->scheduler = NULL;
>   request->handle = handle++;
The problem with this code is that it starts from 0, while the specification ( https://wiki.gnome.org/DraftSpecs/ThumbnailerSpec#Request_the_creation_of_thumbnails ) says that the handle can not be 0:
> Queue (Request the creation of thumbnails):
> This method always returns a handle different than 0.
My proposed solution is to change the initial value of the `handle` variable here from 0 to 1. This will change the generated sequence from `0, 1, 2, ...` to `1, 2, 3, ...`. Here is the Merge Request: https://gitlab.xfce.org/xfce/tumbler/-/merge_requests/1
Comment 1 afdw 2020-05-08 01:58:51 CEST
Here is a bug in Thunar which led me to finding this issue: https://bugzilla.xfce.org/show_bug.cgi?id=14122#c1
Comment 2 Markus Elfring 2020-05-08 21:06:46 CEST
(In reply to afdw from comment #0)
> > This method always returns a handle different than 0.
* Will additional checks be needed so that the zero handle will never be returned?
* Should calling programs choose an error response for a received zero handle?
Comment 3 afdw 2020-05-08 22:29:02 CEST
(In reply to Markus Elfring from comment #2)
> (In reply to afdw from comment #0)
> > > This method always returns a handle different than 0.
> * Will additional checks be needed so that the zero handle will never be
> returned?

No, I do no think additional checks in Tumbler are needed as longs as there are no more related bugs.
Comment 4 Markus Elfring 2020-05-09 07:03:20 CEST
(In reply to afdw from comment #3)
> No, I do no think additional checks in Tumbler are needed as longs as there are no more related bugs.
How do you think about the possibility that the used counter would wrap around so that a zero handle could eventually be returned again for a request so far?
Comment 5 Markus Elfring 2020-05-09 07:11:05 CEST
(In reply to afdw from comment #0)
…
> https://gitlab.xfce.org/xfce/tumbler/-/blob/3520322eb453ee1349b14b080a0f7d23e4040b16/tumblerd/tumbler-scheduler.c#L264 ):
> > TumblerSchedulerRequest *
> > tumbler_scheduler_request_new (TumblerFileInfo    **infos,
> >                                TumblerThumbnailer **thumbnailers,
> >                                guint                length,
> >                                const gchar         *origin)
> > {> >   static gint              handle  = 0;> >   request->handle = handle++;
> The problem with this code is that it starts from 0, …
How do you think about the possibility to replace the increment operator instead?
  request->handle = ++handle;
Comment 6 afdw 2020-05-10 02:23:37 CEST
(In reply to Markus Elfring from comment #4)
> (In reply to afdw from comment #3)
> > No, I do no think additional checks in Tumbler are needed as longs as there are no more related bugs.
> How do you think about the possibility that the used counter would wrap
> around so that a zero handle could eventually be returned again for a
> request so far?

(In reply to Markus Elfring from comment #5)
> (In reply to afdw from comment #0)
> …
> > https://gitlab.xfce.org/xfce/tumbler/-/blob/3520322eb453ee1349b14b080a0f7d23e4040b16/tumblerd/tumbler-scheduler.c#L264 ):
> > > TumblerSchedulerRequest *
> > > tumbler_scheduler_request_new (TumblerFileInfo    **infos,
> > >                                TumblerThumbnailer **thumbnailers,
> > >                                guint                length,
> > >                                const gchar         *origin)
> > > {
> …
> > >   static gint              handle  = 0;
> …
> > >   request->handle = handle++;
> > The problem with this code is that it starts from 0, …
> How do you think about the possibility to replace the increment operator
> instead?
>   request->handle = ++handle;

Answered on GitLab.
Comment 7 Markus Elfring 2020-05-18 08:46:25 CEST
(In reply to afdw from comment #6)
> Answered on GitLab.
I find that implementation details should get further software development attention also for this issue.

* Correct data type for the request handle
  https://bugzilla.xfce.org/show_bug.cgi?id=16833

* Make request management safer
  https://bugzilla.xfce.org/show_bug.cgi?id=16842

Bug #16814

Reported by:
afdw
Reported on: 2020-05-08
Last modified on: 2020-05-18

People

Assignee:
Ali Abdallah
CC List:
1 user

Version

Attachments

Additional information