> You are not going to try and debug the crash? If the code is *that* bad,
> then alright ;) But we should raise a bug upstream so we can apply any
> patch they might provide.
The crash is always in maxval due to a negative index.
961 return(x[imax]);
where imax = -1 from
952 for (imax=-1,i=index0-dx2-n0;i<=index0+dx2-n0;i++)
because index0 = - 71, dx2 = 0 and n0 = 0 so the loop never iterates.
You can try going up and down the stack, but I can't tell what those
variables do or what their expected output should be.
Here is a hackish fix available on github (does it fix things for you too?)
%-------------------------------------------------------------------------------
$OpenBSD$
Index: k2pdfoptlib/textrows.c
--- k2pdfoptlib/textrows.c.orig
+++ k2pdfoptlib/textrows.c
@@ -956,6 +956,11 @@ static int maxval(int *x,int n,int n0,int dx,int *inde
if (imax<0 || x[i]>x[imax])
imax=i;
}
+ if (imax < 0) /* handle negative index by returning the first entry */
+ if (index)
+ (*index)=0;
+ return(x[0]);
+
if (index!=NULL)
(*index)=imax+n0;
return(x[imax]);
%-------------------------------------------------------------------------------
and here is the full stack trace
%-------------------------------------------------------------------------------
Program received signal SIGSEGV, Segmentation fault.
0x00001fa7dfe27510 in maxval (x=0x1faa35bcb000, n=5550, n0=0, dx=3,
index=0x7f7ffffcc0a4, index0=-71)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/textrows.c:961
961 return(x[imax]);
(gdb) bt
#0 0x00001fa7dfe27510 in maxval (x=0x1faa35bcb000, n=5550, n0=0, dx=3,
index=0x7f7ffffcc0a4, index0=-71)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/textrows.c:961
#1 0x00001fa7dfe26d24 in textrows_find_doubles (textrows=0x7f7ffffcc438,
rowthresh=0x1faa35bcb000, region=0x7f7ffffcc428,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>, maxsize=3,
dynamic_aperture=0)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/textrows.c:717
#2 0x00001fa7dfe2b8a3 in bmpregion_find_textrows (region=0x7f7ffffcc428,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>,
dynamic_aperture=0, remove_small_rows=1, join_figure_captions=1)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/bmpregion.c:1482
#3 0x00001fa7dfe1436f in masterinfo_add_bitmap (
masterinfo=0x1fa7e0114d70 <k2pdfopt_proc_one._masterinfo>,
src=0x7f7ffffced30,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>, npageboxes=1,
justification_flags=143, whitethresh=192, nocr=2, dpi=588,
wrectmaps=0x7f7ffffceb28, textrow0=0x7f7ffffceae0)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2master.c:537
#4 0x00001fa7dfe3caf5 in bmpregion_add (added_region=0x7f7ffffd0618,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>,
masterinfo=0x1fa7e0114d70 <k2pdfopt_proc_one._masterinfo>)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2proc.c:1611
#5 0x00001fa7dfe401e5 in bmpregion_add_textrows (added_region=0x7f7ffffd07f8,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>,
masterinfo=0x1fa7e0114d70 <k2pdfopt_proc_one._masterinfo>)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2proc.c:2685
#6 0x00001fa7dfe395e3 in bmpregion_vertically_break (region=0x1faad30890c8,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>,
masterinfo=0x1fa7e0114d70 <k2pdfopt_proc_one._masterinfo>, force_scale=-2,
source_page=2, ncols=2, notes=0x0)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2proc.c:2550
#7 0x00001fa7dfe3a4d0 in bmpregion_source_box_process (region=0x7f7ffffd0cb8,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>,
masterinfo=0x1fa7e0114d70 <k2pdfopt_proc_one._masterinfo>, level=1,
pages_done=2)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2proc.c:463
#8 0x00001fa7dfe39cf6 in bmpregion_source_page_add (region=0x7f7ffffd0cb8,
k2settings=0x1fa7e010e750 <k2pdfopt_proc_one._k2settings>,
masterinfo=0x1fa7e0114d70 <k2pdfopt_proc_one._masterinfo>, level=1,
pages_done=2)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2proc.c:170
#9 0x00001fa7dfe102da in k2pdfopt_proc_one (
k2settings0=0x1fa7e0101aa8 <main._k2conv>,
filename=0x7f7ffffd4c30
"/home/bulibuta/doc/research/sparse/2D/FuGaoSunHong14_TKSVD.pdf",
k2fileproc=0x7f7ffffd49f0)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2file.c:862
#10 0x00001fa7dfe0e9a4 in k2pdfopt_preprocess_single_doc (
k2settings=0x1fa7e0101aa8 <main._k2conv>,
srcfilename=0x7f7ffffd50a0
"/home/bulibuta/doc/research/sparse/2D/FuGaoSunHong14_TKSVD.pdf",
k2listproc=0x7f7ffffd5c48)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2file.c:339
#11 0x00001fa7dfe0cd91 in k2pdfopt_proc_file_or_folder (
k2settings=0x1fa7e0101aa8 <main._k2conv>,
filename=0x1faab4a42d80
"/home/bulibuta/doc/research/sparse/2D/FuGaoSunHong14_TKSVD.pdf",
k2listproc=0x7f7ffffd5c48)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2file.c:172
#12 0x00001fa7dfe0cae3 in k2pdfopt_proc_wildarg (
k2settings=0x1fa7e0101aa8 <main._k2conv>,
arg=0x1faab4a42d80
"/home/bulibuta/doc/research/sparse/2D/FuGaoSunHong14_TKSVD.pdf",
k2listproc=0x7f7ffffd5c48)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2file.c:109
#13 0x00001fa7dfe028cf in main (argc=6, argv=0x7f7ffffd5cb8)
at /usr/ports/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfopt.c:245
%-------------------------------------------------------------------------------