Skip to content

Change bsdiff's suffix sort algorithm to sais. Fixes #132#515

Merged
kornelski merged 1 commit intosparkle-project:masterfrom
zorgiepoo:bsdiff-sais
Apr 5, 2015
Merged

Change bsdiff's suffix sort algorithm to sais. Fixes #132#515
kornelski merged 1 commit intosparkle-project:masterfrom
zorgiepoo:bsdiff-sais

Conversation

@zorgiepoo
Copy link
Copy Markdown
Member

Although #132 is marked as closed, the issue is still real. bsdiff can crash or hang when creating diffs on some files. In particular, bsdiff hangs/crashes in its recursive split function.

As you can see from:
http://stackoverflow.com/a/20305493/871119
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664

bsdiff 4.3 uses qsufsort for its suffix sorting algorithm, which has a bug causing the hanging/crashing. Our solution is to change the algorithm to use sais for suffix sorting:
https://sites.google.com/site/yuta256/sais

Notes:

  • I had to change sais_index_type #define from int to off_t in sais.h/c and in some other places, to eliminate all warnings. Compiles cleanly with clang's -Weverything
  • sais is claimed to be more efficient than other algorithms including qsufsort. If a more efficient (and stable) algorithm comes out, we may be able to swap it out in the future.

I'll start to look into writing actual tests soon. Going through other people's issues/tests just seems to prioritize higher ;).



Although sparkle-project#132 is marked as closed, the issue is still real. bsdiff can crash or hang when creating diffs on some files. In particular, bsdiff hangs/crashes in its recursive split function.

As you can see from:
http://stackoverflow.com/a/20305493/871119
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664

bsdiff 4.3 uses qsufsort for its suffix sorting algorithm, which has a bug causing the hanging/crashing. Our solution is to change the algorithm to use sais for suffix sorting:
https://sites.google.com/site/yuta256/sais

Notes:
*I had to change sais_index_type #define from int to off_t in sais.h/c and in some other places, to eliminate all warnings. Compiles cleanly with clang's -Weverything
*sais is claimed to be more efficient than other algorithms including qsufsort. If a more efficient (and stable) algorithm comes out, we may be able to swap it out in the future.
@kornelski
Copy link
Copy Markdown
Member

Thanks for the fixes.

It's curious that the issue hasn't been fixed upstream. There's a fork with a PR with sais as well but unfortunately it's not compatible.

…which makes me wonder, is this modification backwards-compatible with existing diffs?

@zorgiepoo
Copy link
Copy Markdown
Member Author

Hm, that's interesting. Looks like the PR request for that repo got their fix idea from the same person I did in that Stack Overflow thread.

That fork of bsdiff is not intended to be compatible with the original bsdiff version that we use, which is not related to using sais. My pull request shouldn't require changes to bspatch.

kornelski added a commit that referenced this pull request Apr 5, 2015
Change bsdiff's suffix sort algorithm to sais. Fixes #132
@kornelski kornelski merged commit 21999e4 into sparkle-project:master Apr 5, 2015
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 14, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 15, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 15, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 15, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 16, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 16, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 16, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 16, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 17, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 17, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 17, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 20, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 21, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 22, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 22, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 22, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 22, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 22, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 23, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 23, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 29, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 29, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
glevand added a commit to glevand/coreos--coreos-overlay that referenced this pull request Jul 30, 2015
To avoid dependencies on dev-libs/libdivsufsort and dev-util/cmake convert bsdiff
from using the divsufsort suffix sort to using the sais-lite suffix sort from [1].

The need for an alternative suffix sort is discussed in [2] through [4].  A
dependency on dev-util/cmake is problematic as cmake cannot be cross-compiled and
a switch to sais-lite avoids this dependency.

 [1] https://sites.google.com/site/yuta256/sais
 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
 [3] sparkle-project/Sparkle#515
 [4] https://chromium.googlesource.com/chromiumos/third_party/bsdiff/+/e2b85ce4ea246ca804ee2a9e18005c44e193d868

Signed-off-by: Geoff Levand <geoff@infradead.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants