Bug 5630 - rebase crash on certain cases
Summary: rebase crash on certain cases
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: rebase (show other bugs)
Version: 4.3-rc
Hardware: All All
: wish bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-25 02:01 UTC by Jun Wu
Modified: 2021-07-06 08:23 UTC (History)
3 users (show)

See Also:
Python Version: ---


Attachments
Script that triggers the error. (1.18 KB, application/x-shellscript)
2021-07-06 08:19 UTC, Jacco van Schaik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jun Wu 2017-07-25 02:01 UTC
Using 6192a67b7962. This was found as a side effect of working on issue5627 fix.

  $ cat >> $HGRCPATH<<EOF
  > [extensions]
  > rebase=
  > drawdag=$TESTDIR/drawdag.py
  > [experimental]
  > evolution=createmarkers, allowunstable
  > EOF

Case 1

  $ hg init
  $ hg debugdrawdag <<'EOS'
  >      E
  >     /|
  >    | D
  >    | |
  >    | C
  >    |/
  >  B F
  >  |/
  >  A
  > EOS

  $ hg rebase -r C+E -d B
  .... (crash) ....
  AssertionError: no base found to rebase on (defineparents called wrong)

Case 2 (only rev numbers are different from Case 1, but different crash)

  $ rm -rf .hg
  $ hg init
  $ hg debugdrawdag <<'EOS'
  >      E
  >     /|
  >    | D
  >    | |
  >    | C
  >    |/
  >  F B
  >  |/
  >  A
  > EOS

  $ hg rebase -r C+E -d F
  .... (crash) ....
  ValueError: revlog index out of range

Case 3 (copy Case 1 with "G" added, to be more realistic)

  $ rm -rf .hg
  $ hg init
  $ hg debugdrawdag <<'EOS'
  >      E
  >     /|
  >    | D
  >    | |
  >    G C
  >    |/
  >  B F
  >  |/
  >  A
  > EOS
  $ hg rebase -r C+E -d B
  .... (crash) ....
  ValueError: revlog index out of range

I believe there are many more interesting test cases, and https://phab.mercurial-scm.org/D21 stack fixes all the crashes with some reasonable behavior.
Comment 1 Yuya Nishihara 2017-07-26 09:53 UTC
The first case looks somewhat similar to the issue 5578.
Comment 2 Jun Wu 2017-09-06 20:39 UTC
Fixed by https://phab.mercurial-scm.org/D21
Comment 3 HG Bot 2017-10-04 18:07 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/0975506120fb
Jun Wu <quark@fb.com>
rebase: rewrite core algorithm (issue5578) (issue5630)

"defineparents" is the core algorithm of rebase. The old code has too many
tech debts (like outdated comments, confusing assertions, etc) and is very
error-prone to be improved. This patch rewrites "defineparents" to make the
code easier to reason about, and solve a bunch of issues, including:

  - Assertion error: no base found (demonstrated by D212, issue5578)
  - Asymmetric result (demonstrated by D211, "F with one parent")
  - Wrong new parent (demonstrated by D262, "C':A'A'")
  - "revlog index out of range" (demonstrated by D262, issue5630)
  - "nothing to merge" (demonstrated by D262)

As a side effect, merge base decision has been made more solid - rebase now
prints out explicitly what could go wrong when it cannot find a unique
suitable merge base.

.. fix:: Issue 5578, Issue 5630

   Core rebase algorithm has been rewritten to be more robust.

Differential Revision: https://phab.mercurial-scm.org/D21

(please test the fix)
Comment 4 Bugzilla 2017-10-18 00:00 UTC
Bug was set to TESTING for 13 days, resolving
Comment 5 Jacco van Schaik 2021-07-06 08:19 UTC
Created attachment 2118 [details]
Script that triggers the error.
Comment 6 Jacco van Schaik 2021-07-06 08:23 UTC
Comment on attachment 2118 [details]
Script that triggers the error.

My apologies, this was submitted on the wrong bug report. I'd remove it myself but I can't find how to do that. Please disregard.