Bug 442618 - KDiff3 crashes on a git merge conflict with "Severe Internal Error line != i for srcSelector= 1"
Summary: KDiff3 crashes on a git merge conflict with "Severe Internal Error line != i ...
Status: RESOLVED FIXED
Alias: None
Product: kdiff3
Classification: Applications
Component: application (other bugs)
Version First Reported In: 1.9.3
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: michael
URL:
Keywords:
: 447996 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-09-17 21:06 UTC by vlovich
Modified: 2023-04-22 19:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 1.10.2
Sentry Crash Report:


Attachments
3 files to reproduce Severe Internal Error (1.78 KB, application/x-xz)
2022-03-11 16:25 UTC, Tiago Moraes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vlovich 2021-09-17 21:06:09 UTC
SUMMARY
I've observed Kdiff3 sporadically failing to open certain merge conflicts.
On the command-line it prints "Severe Internal Error."  line != i for srcSelector= 1.

STEPS TO REPRODUCE
Running git mergetool on a file that conflicts. Not really sure what is it about the merge conflict & haven't figured out how to reduce this to a more standalone case.

OBSERVED RESULT
org.kde.kdiff3: "Loading A: somefile_BASE_1458148.c++"
org.kde.kdiff3: "Loading B: somefile_LOCAL_1458148.c++"
org.kde.kdiff3: "Loading C: somefile_REMOTE_1458148.c++"
org.kde.kdiff3: "Diff: A <-> B"
org.kde.kdiff3: Enter: calcDiff3LineListUsingAB
org.kde.kdiff3: Leave: calcDiff3LineListUsingAB
org.kde.kdiff3: "Diff: A <-> C"
org.kde.kdiff3: "Diff: B <-> C"
org.kde.kdiff3: "Severe Internal Error."  line != i for srcSelector= 1 


EXPECTED RESULT
The merge conflict should open


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
(available in About System)
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Kdiff3 1.9.3 (64 bit)

ADDITIONAL INFORMATION
My gitconfig has 
[merge]
    tool = kdiff3
    conflictstyle = diff3
if that matters. When I delete the attached kdiff3rc file the merge succeeds.
Comment 1 vlovich 2021-09-17 21:09:23 UTC
The problematic setting appears to be Diff3AlignBC=true. If I set that to false the crash resolves.
Comment 2 Tiago Moraes 2022-03-11 16:25:42 UTC
Created attachment 147446 [details]
3 files to reproduce Severe Internal Error

I can reproduce this on KDiff3 Version 1.9.5 (64 bit), the files are from an OSS project so I attached them here.
To reproduce save the 3 in the attachment to a folder and run kdiff3 base.exs local.exs remote.exs

org.kde.kdiff3: "Loading A: base.exs"
org.kde.kdiff3: "Loading B: local.exs"
org.kde.kdiff3: "Loading C: remote.exs"
org.kde.kdiff3: "Diff: A <-> B"
org.kde.kdiff3: Enter: calcDiff3LineListUsingAB
org.kde.kdiff3: Leave: calcDiff3LineListUsingAB
org.kde.kdiff3: "Diff: A <-> C"
org.kde.kdiff3: "Diff: B <-> C"
org.kde.kdiff3: "Severe Internal Error."  line != i for srcSelector= 1
Comment 3 michael 2022-03-24 17:18:06 UTC
*** Bug 447996 has been marked as a duplicate of this bug. ***
Comment 4 michael 2022-03-24 17:19:26 UTC
Looks like some else got a minimal repo on this linked as dup so it doesn't get lost again.
Comment 5 michael 2022-03-24 18:27:31 UTC
Weirdly both these cases work on my machine with the latest commits on master and 1.9. The 1.9 has two unrelated bug fixes which wouldn't have impacted the diff process. That's on comparing the files via the GUI and contextual menu.
Comment 6 svist 2022-12-29 00:27:46 UTC
@michael
See the duped bug, you need to enable option "Align B and C for 3 input files" -- that's when the crashes happen.

I'm currently on 1.9.6 and it's still crashing with the example files
Comment 7 michael 2023-03-24 21:52:21 UTC
The current stable branch is 1.10.x this appears fixed there and in master however I have no recollection of the exact  commit. Awaiting confirmation.
Comment 8 michael 2023-04-22 19:16:01 UTC
Finally got a reproducible error for a different input set.  Turns out this is a defective check that does not always work properly if Diff3AlignBC=true. This a result how the alignment adjustment works specifically m_diff3LineList can have multiple references to a line in one file if its replaced by multiple lines in another. This appears to be specific to aligning B and C. There appears to be no real problem beyond this and the check is now disabled in this case.