Bug 382456 - Amarok APG: crashes if checkpoint is unassigned in CheckpointConstraint
Summary: Amarok APG: crashes if checkpoint is unassigned in CheckpointConstraint
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Playlists/Automated Playlist Generator (show other bugs)
Version: 2.8.90 (2.9 beta)
Platform: Other Linux
: NOR normal
Target Milestone: 2.9
Assignee: Soren Harward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-18 08:05 UTC by p92
Modified: 2024-05-16 15:23 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
the apl model with empty checkpoint condition that crashes amarok (39.69 KB, image/png)
2017-07-18 08:05 UTC, p92
Details

Note You need to log in before you can comment on or make changes to this bug.
Description p92 2017-07-18 08:05:31 UTC
Created attachment 106703 [details]
the apl model with empty checkpoint condition that crashes amarok

amarok allows me to generate an incomplete model of APL using an incomplete "checkpoint" constraint.

to reproduce start with for example this APL model :
pascal@minipc:~$ cat Musique/classiques3.xml 
<?xml version="1.0" encoding="UTF-8"?>
<playlistgenerator>
  <generatorpreset title="classiques3">
    <constrainttree>
      <group matchtype="all">
        <constraint field="genre" comparison="3" invert="false" type="TagMatch" value="Classical" strictness="0.1"/>
      </group>
    </constrainttree>
  </generatorpreset>
</playlistgenerator>

then just 
add a "checkpoint" constraint to the constrainttree (see screenshot)
but do not select anything as checkpoint parameters, 
just adjust strictness of checkpoint to exact
click OK

the new model is saved

when editing this model you see the 2 constraints are there as in the screenshot but when exporting this model to a file the "checkpoint" constraint is absent !

now try to execute this model ==> amarok crashes 

running in debug mode gives this upon executing this incomplete model :

pascal@minipc:~$ amarok: [APG::ConstraintSolver] New ConstraintSolver with serial number 967666005 
amarok: [APG::ConstraintNode] new constraint node at 0x31de3f90 with parent at 0x2f6023f0 
amarok: [APG::ConstraintSolver] Domain has 4376 tracks 
amarok: [APG::ConstraintSolver] Running ConstraintSolver 967666005 
amarok: Fatal IO error: client killed
Unable to start Dr. Konqi
Not forwarding the crash to Apport.
Comment 1 Tuomas Nurmi 2024-04-23 20:20:11 UTC
Reproducible with 2.9.82. Let's see if I'll come up with a fix sometime
Comment 2 Bug Janitor Service 2024-05-05 21:51:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/multimedia/amarok/-/merge_requests/94
Comment 3 Tuomas Nurmi 2024-05-06 15:15:15 UTC
Git commit 25b763728031b9737f8dce80653086fb0a05e3fc by Tuomas Nurmi.
Committed on 06/05/2024 at 15:14.
Pushed by nurmi into branch 'master'.

Prevent crash in APG when constraint is missing data

I'm not familliar enough with APG to properly assess if the fact noted on the
bug report, that amarok allows to generate an incomplete constraint, should be
fixed or not, but at least it shouldn't crash. So let's fix that.

M  +2    -2    ChangeLog
M  +2    -0    src/playlistgenerator/constraints/Checkpoint.cpp

https://invent.kde.org/multimedia/amarok/-/commit/25b763728031b9737f8dce80653086fb0a05e3fc
Comment 4 Soren Harward 2024-05-16 01:13:06 UTC
(In reply to Tuomas Nurmi from comment #3)
> Git commit 25b763728031b9737f8dce80653086fb0a05e3fc by Tuomas Nurmi.
> Committed on 06/05/2024 at 15:14.
> Pushed by nurmi into branch 'master'.
> 
> Prevent crash in APG when constraint is missing data
> 
> I'm not familliar enough with APG to properly assess if the fact noted on the
> bug report, that amarok allows to generate an incomplete constraint, should
> be
> fixed or not, but at least it shouldn't crash. So let's fix that.
> 
> M  +2    -2    ChangeLog
> M  +2    -0    src/playlistgenerator/constraints/Checkpoint.cpp
> 
> https://invent.kde.org/multimedia/amarok/-/commit/
> 25b763728031b9737f8dce80653086fb0a05e3fc

Return 1.0 as the value in line 212.

If the user hasn't specified a track for the checkpoint, then the logical behavior is that any track will satisfy the constraint. So the APG solver will work better if the constraint always reports that it's 100% satisfied when the track is unspecified.
Comment 5 Tuomas Nurmi 2024-05-16 15:23:32 UTC
Sounds good, makes sense. Change committed in https://invent.kde.org/multimedia/amarok/-/commit/aad011a2ab722fd363870e7aa502e1663bee33bc - thank you for the comment!