[NR] Application Crashes When Creating Sibling Category

Started by Jeff Mason, December 26, 2022, 04:21:45 AM

Previous topic - Next topic

Jeff Mason

For the Categories construct @all|Child|Sibling|Sibling, when I create a formula for the second sibling using either @Category or @Metadata, the application terminates. The database can not be opened successfully and requires a restore (which has it's own problems that I will address in another topic).

I can successfully create a @all|Child|Sibling|Sibling structure using @Folder formulas.

Mario

#1
Does IMatch just close or does Windows produce a bug report with a DUMP file after a short while?
See The Debug Dump File for more information.

If you report a bug, please always include the log file from that session (make a copy of the log file before restarting IMatch, ZIP and attach to your post (or send to support email address) with a link to the community topic.

The log file will contain important information that will be helpful for problem analysis.

I'm not sure that I understand your category hierarchy.

@All|Child|Sibling|Sibling is not possible.

Do you have something like

@All
  |-C
    |-S1
    |-S2

Then you would get these possible paths:

@All|C
@All|C|S1
@All|C|S2

Or does your category hierarchy look different?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jeff Mason

Mario,

Once again, thank you for your prompt response.

Screenshot1 attached shows the category structure just before the application terminates. At this point, I have not entered a category formula for the "Vault" sibling.

There is no category formula for the "Memory Books" category.

The category formula for the "JWM" child is: "@MetadataTag[XMP::iptcExt\PersonInImage\PersonInImage\0,contains-any,James Whittemore]". This formula works as expected.

The category formula for the "Final" child is: "@Category[Memory Books\|JWM]" AND "@MetadataTag[XMP::xmp\Label\Label\0,contains-words,Final]". This formula executes works as expected.

The attempted category formula for the "Vault" sibling is:"@Category[Memory Books\|JWM]" AND "@MetadataTag[XMP::xmp\Label\Label\0,notcontains-any,Final]". Entry of this formula terminates the application. At termination, the application window closes and there is no dialog box displayed nor DUMP file created.

Also attached is the LOG file, created using the Debug option.

Mario

IMatch should not crash of course, but the problem is that your formula is self-referencing, producing an infinite loop.

Vault is a child category of JVM and your formula for Vault references JVM,
To calculate the formula for Vault, IMatch has to calculate JVM. And to calculate JVM, it has to calculate Vault. And to calculate Vault, it has to calculate JVM => infinite loop.

IMatch usually deals with this gracefully and abandons, setting the error state for the category.
I'll check for the bug, but your formula cannot work. Keep in mind that a parent category always 'contains' all files of its child categories.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mario

I have fixed the crash caused by the invalid formula.

You cannot reference JVM in any of it's children via a formula.

If you do something like this

@All
|- MemoryBooks
  |- JVM

|- MemoryBookData
  |- JVM
    |- Approved
     |- Vault
    |- Publish
 
your formulas will work if they reference MemoryBooks|JVM (but not MemoryBooksData|...).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jeff Mason

I think I tried your suggestion, but it still didn't work.

Here's what I tried.

@All
|People
   |JWM Category Formula: "@MetadataTag[XMP::iptcExt\PersonInImage\PersonInImage\0,contains-any,James Whittemore]"

|Memory Books
   |JWM
      |0-10 Category Formula: "@Category[People|JWM]" AND "@MetadataTag[XMP::xmp\Label\Label\0,contains-words,Final]" AND "@MetadataTag[PLUS::XMP\Custom1\Custom1\0,between,1939.10,1949.10]"
      |10-20 Category Formula: "@Category[People|JWM]" AND "@MetadataTag[XMP::xmp\Label\Label\0,contains-words,Final]" AND "@MetadataTag[PLUS::XMP\Custom1\Custom1\0,between,1949.10,1959.10]"

As soon as I entered the category formula for child 10-20, the application window closed with no DEBUG file created. I had to restore the database.

As an aside, I couldn't figure out how to extract by name a specific individual's age from the File.Person.Age variable, hence the workaround shown above.

Mario

How obscure. I shall try to reproduce this tomorrow evening.
Thanks for providing a full example. Category formula bugs are so rare, the last time I made changes in this area was maybe 3 years ago :D

Note than you must escape | with a leasing \ => \|
(If you don't start with @All).

| has a special meaning in regular expressions. See @Category[] for all details.


QuoteAs soon as I entered the category formula for child 10-20, the application window closed with no DEBUG file created. I had to restore the database.

Of course IMatch will recalculate the category when it restarts, causing the immediate shut-down again.
Just do a copy Ctrl+C, Ctr+V for the database file after closing IMatch successfully (no .wal file in the folder).
This makes restore quick if needed.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mario

I could not reproduce this.
Maybe I have fixed this with my change explained above. But your second example does not cause infinite loops when the regexp is correct:

Make sure you always us \| and not only |
Because | means "or" in regular expressions and you may get a lot of unwanted categories in your result that way.

When you use between and reference tags which are in text format (like your PLUS custom), allow for a larger range to avoid issues caused by converting text into floating point numbers.

For example, use between,1949.05,1959.15] to allow for rounding errors during conversion,
The 1949.10 may end up as 1949.0999999999 internally (that's just how text to load conversions work).


QuoteAs an aside, I couldn't figure out how to extract by name a specific individual's age from the File.Person.Age variable, hence the workaround shown above.

Category formulas cannot calculate person ages. At least not yet.
You can work-around this by creating a data-driven category based on the Person.Age variable. This groups all persons in your database by age. Or age cluster / age range, depending on how you use the variable.

Then use a @Category formula to reference the, say, 0-10 year data-driven category in your 0-10 category.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jeff Mason

Well sir, thank you for your help. I have tried your suggestions as well as other category formulas, but so far nothing I have tried works. Either the database still closes down with no DEBUG file generated or I get results that don't match my expectations.

I have read the @Category Help as suggested. I think my problem is that I think that each child draws from its parent's scope, but my category formulas don't produce this outcome, and I can't figure out why.

So perhaps this thread is not so much a bug report as it is a user problem.

Mario

Categories always 'contain' the files in their child categories, recursively.

You cannot reference a parent category in any form in a formula of a child category. The parent must evaluate all children to produce its output, and when attempting to evaluate the child which refers it (the parent), an infinite loop occurs and IMatch has to stop and flat the category as "in error" (red stop sign).

You found a loophole by using a @Category regular expression which basically grabs all categories under People (by using | instead of \|) and this caused IMatch to fail to detect the infinite loop and it had to close itself.

This I have fixed for IMatch 2023. Since this bug existed for many years and was never reported, I gave it a low priority rating.

Your second example works here.
I've copied the formulas into the same category layout, prepared some images with the label name and the PLUS Custom tag and the outcome is as I would expect. After adding a bit of leeway to the between calculations to accommodate for the floating point numeric.

I don't see how this, used with the correct \| regular expression could cause an infinite loop...

People|JWM  => People or JVM
People\|JWM  => People\JVM

Category formulas are a somewhat advanced topic and may require some fiddling to get them right. Many IMatch users out there never use category formulas or know about their existence.

Since you work with Boolean logic, I suggest you start with one formula element first and check the result. Then do the same with the second part of the formula. Then combine them with AND or OR. This usually makes it easier to understand if the result is as expected.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook