Bug 509197

Summary: segfault when loading a puzzle
Product: [Applications] palapeli Reporter: samuel.kister <samuel.kister>
Component: generalAssignee: Stefan Majewsky <majewsky>
Status: REPORTED ---    
Severity: crash CC: aacid, kde-games-bugs-null, samuel.kister
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description samuel.kister@gmail.com 2025-09-06 15:41:27 UTC
SUMMARY
After upgrading to Ubuntu 25.04 and creating a new puzzle with 2 pieces holers, Palapeli crashed with a segmentation fault on reloading this puzzle.
Palapeli Version is 2.1.25043, from official Ubuntu depot. 

STEPS TO REPRODUCE
1. Create a puzzle
2. Create some holders
3. Close the puzzle
4. Reload the puzzle

OBSERVED RESULT
From KDE: Application not responding dialog or just closing.
From shell: segmentation fault message

ADDITIONAL INFORMATION
The fault is in the puzzle ".save" file, where "N_Holders" is saved with value "-1"!
I could not find why an could also not reproduce it since, but have made a small workaround patch to be able to load the puzzle in this situation (it's bad to loose a 1'000 pieces puzzle with contour and some background pieces already sorted). Patch for actual main branch in KDEInvent git:

Index: src/engine/gameplay.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/engine/gameplay.cpp b/src/engine/gameplay.cpp
--- a/src/engine/gameplay.cpp	(revision ad651690fcb6890e7fa23e22d037e20ee3081c2c)
+++ b/src/engine/gameplay.cpp	(date 1757168192413)
@@ -880,9 +880,19 @@
 
 		// Re-create the saved piece-holders, if any.
 		m_currentHolder = nullptr;
-		for (int groupID = 1; groupID <= nHolders; groupID++) {
+
+		// BUG: in new format, number of holders is saved with value "-1"
+		// Recreate holders by trying
+		for (int groupID = 1; (nHolders == -1) || (groupID <= nHolders); groupID++) {
 			KConfigGroup holder (&savedConfig,
 					QStringLiteral("Holder_%1").arg(groupID));
+
+			// BUG: if this group doesn't exist, we reached the end of the list
+			if (not holder.exists())
+			{
+					break;
+			}
+
 			// Re-create a piece-holder and add it to m_viewList.
 			qCDebug(PALAPELI_LOG) << "RE-CREATE HOLDER"
 				 << QStringLiteral("Holder_%1").arg(groupID) << "name"
Comment 1 Albert Astals Cid 2025-09-06 20:25:03 UTC
I can not reproduce it.

What do you mean exactly with "3. Close the puzzle"?
Comment 2 samuel.kister@gmail.com 2025-09-08 09:58:40 UTC
Hello,

By "closing the puzzle", I mean go back to collection.

I could also no more reproduce it since I began to search in the code 
for the fault (also with the Ubuntu "official" version). I suspect a 
fault in some QT library (handling QList type) that is not present in 
the "dev" version (or was already corrected).

I may have some virtual machine with Ubuntu that I can upgrade and 
recheck without "dev" environment, I will keep you informed.

I had the fault on 2 puzzles I created from different images, one with 
5'000 pieces, the other with 1'000, with 1 or 2 holders created at the 
beginning, after deleting the auto-generated "main".

Best regards.

KISTER Samuel

Le 06/09/2025 à 22:25, Albert Astals Cid a écrit :
> https://bugs.kde.org/show_bug.cgi?id=509197
>
> Albert Astals Cid <aacid@kde.org> changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>               Status|REPORTED                    |NEEDSINFO
>           Resolution|---                         |WAITINGFORINFO
>                   CC|                            |aacid@kde.org
>
> --- Comment #1 from Albert Astals Cid <aacid@kde.org> ---
> I can not reproduce it.
>
> What do you mean exactly with "3. Close the puzzle"?
>
Comment 3 Bug Janitor Service 2025-09-23 03:47:00 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 4 samuel.kister@gmail.com 2025-09-30 17:02:54 UTC
I could reproduce the bug with the version I signaled (2.1.25043).
It's only happening if I close the Palapeli window while in the puzzle, WITHOUT going back to the collection before.
If I go back to the collection first and then closes the window, the value is written correctly.

It also don't do it false with the debug version I've compiled myself.
Comment 5 Bug Janitor Service 2025-10-15 03:47:12 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!