Project

General

Profile

Bug #12277

Incorrect behaviour of types.dt_lua_tag_t.#

Added by Christian G 3 months ago. Updated 9 days ago.

Status:
New
Priority:
Low
Category:
Lua
Target version:
-
Start date:
08/02/2018
Due date:
% Done:

0%

Affected Version:
2.4.2
System:
Ubuntu
bitness:
64-bit
hardware architecture:
amd64/x86

Description

Accessing values of type types.dt_lua_tag_t by a numbered index (e.g. types.dt_lua_tag_t[3]) actually returns the images that have that tag attached to them, according to documentation. But there seems to be an indexing bug:
  • accessing the first value (types.dt_lua_tag_t[1]) crashes the application
  • accessing the second value (types.dt_lua_tag_t[2]) returns the first image
  • accessing the third value (types.dt_lua_tag_t[3]) returns the second image, etc.
  • the length operator (#types.dt_lua_tag_t) returns the number of images attached with that tag plus 1

tag_index_test.lua (483 Bytes) Bill Ferguson, 09/12/2018 08:45 PM

History

#1 Updated by Bill Ferguson about 1 month ago

Tried to recreate this problem and failed. Randomly tagged 6 images with "test" then wrote a script (attached) to check the results. The script returned the correct number of images and the correct image filenames.

#2 Updated by Christian G about 1 month ago

Ok, I have to state description more precisely. This bug does not always occur, it occured sometimes. When I run tag_index_test.lua now it generates expected results. I'll further observe this strange behaviour.

#3 Updated by Christian G about 1 month ago

I did some further tests. Since I also observed problems using ipairs() on values of type types.dt_lua_tag_t before, I tried this again with your example script. I changed lines 18 - 21 from

  for i = 1, #test_tag do
    dt.print_log("image is " .. test_tag[i].filename)
  -- do
  end

to

  for _,image in ipairs(test_tag) do
    dt.print_log("image is " .. image.filename)
  -- do
  end

This leads to the following error:

LUA ERROR : incorrect index in database

Is this expected? I actually expected to iterate over each image tagged with test_tag.

And second, does this behaviour maybe have something to do with the described bug above?

#4 Updated by Christian G 9 days ago

I could further isolate the error case stated in the ticket description. I have imported some images into darktable, which contained tags as jpg file meta information, which are converted into darktable tags. When applying tag_index_test.lua on one of these imported tags (I only changed line 15 to the name of that tag), the behaviour from the ticket description could be reproduced. After entering the loop in line 18 with i = 1 accessing test_tag[1] crashed darktable.

So the bug is maybe related to imported tags only, i.e. tags imported from file meta information.

On the other hand the error "incorrect index in database", when using ipairs(), is strange as well.

Also available in: Atom PDF