Re: [UPDATE] textproc/pdfgrep
Reinhold Straub writes: > Hi, > > pdfgrep is hosted on a different server now. Committed, thanks. For the record the diff didn't apply (whitespace change; copy/paste?) and lacked a REVISION bump (since HOMEPAGE changed). -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: [UPDATE] textproc/pdfgrep
Reinhold Straub writes: > Hi, Hi, > there is a new version of pdfgrep. Works for me, committed. Minor nit: indentation should use tabs, not spaces. Thanks, -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: [UPDATE] textproc/pdfgrep
On Fri, Jan 15, 2016 at 10:04:36AM +0100, Reinhold Straub wrote: > Hi, > > pdfgrep has a testsuite based on devel/dejagnu now. Unfortunately, some > patches are necessary to make tests work on OpenBSD. > > I put pledge(2) calls into the source code, too. So where are patches? Did you forget to cvs add it? j.
Re: [UPDATE] textproc/pdfgrep
On 2016/01/15 10:04, Reinhold Straub wrote: > Hi, > > pdfgrep has a testsuite based on devel/dejagnu now. Unfortunately, some > patches are necessary to make tests work on OpenBSD. > > I put pledge(2) calls into the source code, too. Nice. I think the combination of PCRE and (often untrusted) PDF files makes this a useful target for pledge. If people are interested in looking at adding pledge to other ports, I have a little list of other ports where it might be both a) useful and b) reasonably sane. Comments inline: > -# $OpenBSD: Makefile,v 1.3 2015/08/25 16:28:04 jca Exp $ > +# $OpenBSD: Makefile,v 1.4 2015/08/25 16:28:04 jca Exp $ please leave the $OpenBSD lines alone in diffs, CVS handles them automatically. > -MODULES =gcc4 > -MODGCC4_ARCHS = * > -MODGCC4_LANGS = c++ > +MODULES = gcc4 > +MODGCC4_ARCHS = * > +MODGCC4_LANGS = c++ this chunk is replacing good whitespace with bad ;) > +TEST_DEPENDS = devel/dejagnu print/texlive/base and please use the standard format here like most other Makefiles (new line for each dep). Here's a diff including the above, the patches from your tar.gz in the diff (which you can't do easily yourself with anoncvs), and with some other whitespace cleanup. I also added a TEST_FLAGS so we can see what dejagnu is doing. There's one test failure in regex.exp: it seems minor so I won't hold up committing because of this, but do you know what that's about? It is not related to the pledge patch. [...] Running ./pdfgrep.tests/regex.exp ... PASS: Match line after double match PASS: Match line after double match -- fixed string PASS: Match line after double match -- PCRE FAIL: Empty pattern -- error from pdfgrep [...] Anyway it's working fine for me, I've tested with password-protected files as well (and I can't think of any of the command-line options that might change required pledges), so if you're still happy with this I can go ahead and commit. Index: Makefile === RCS file: /cvs/ports/textproc/pdfgrep/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- Makefile25 Aug 2015 16:28:04 - 1.3 +++ Makefile15 Jan 2016 11:56:14 - @@ -2,7 +2,7 @@ COMMENT = tool to search text in PDF files -DISTNAME = pdfgrep-1.4.0 +DISTNAME = pdfgrep-1.4.1 CATEGORIES = textproc @@ -10,22 +10,25 @@ HOMEPAGE = https://pdfgrep.org/ MAINTAINER = Reinhold Straub -#GPLv2+ +# GPLv2+ PERMIT_PACKAGE_CDROM = Yes MODULES = gcc4 MODGCC4_ARCHS =* MODGCC4_LANGS =c++ -WANTLIB += c m pthread stdc++ poppler-cpp pcre +WANTLIB += c m pthread poppler-cpp pcre MASTER_SITES = https://pdfgrep.org/download/ LIB_DEPENDS = print/poppler +TEST_DEPENDS = devel/dejagnu \ + print/texlive/base CONFIGURE_ENV =LDFLAGS="-L${X11BASE}/lib" CONFIGURE_STYLE = gnu MAKE_FLAGS = CXX="${CXX}" +TEST_FLAGS = RUNTESTFLAGS="--all" .include Index: distinfo === RCS file: /cvs/ports/textproc/pdfgrep/distinfo,v retrieving revision 1.2 diff -u -p -r1.2 distinfo --- distinfo25 Aug 2015 16:28:04 - 1.2 +++ distinfo15 Jan 2016 11:56:14 - @@ -1,2 +1,2 @@ -SHA256 (pdfgrep-1.4.0.tar.gz) = MwwRG5GpIRbVpnZsGx0i3NeVkonXNHHZNEsLBHX8quI= -SIZE (pdfgrep-1.4.0.tar.gz) = 125269 +SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw= +SIZE (pdfgrep-1.4.1.tar.gz) = 151926 Index: patches/patch-src_pdfgrep_cc === RCS file: patches/patch-src_pdfgrep_cc diff -N patches/patch-src_pdfgrep_cc --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_pdfgrep_cc15 Jan 2016 11:56:14 - @@ -0,0 +1,27 @@ +$OpenBSD$ +--- src/pdfgrep.cc.origWed Sep 16 21:06:49 2015 src/pdfgrep.cc Fri Jan 15 11:39:19 2016 +@@ -569,6 +569,11 @@ void handle_poppler_errors(const std::string &msg, voi + + int main(int argc, char** argv) + { ++ if (pledge("stdio rpath ioctl", NULL) == -1) { ++ fprintf ( stderr, "pdfgrep: pledge\n" ); ++ exit ( 1 ); ++ } ++ + init_colors(); + + enum re_engine_type { +@@ -773,6 +778,11 @@ int main(int argc, char** argv) + } else if (context == -2) { + // on non-terminals, always print the whole line + context = -1; ++ } ++ ++ if (pledge("stdio rpath", NULL) == -1) { ++ fprintf ( stderr, "pdfgrep: pledge\n" ); ++ exit ( 1 ); + } + + if (excludes_empty(includes)) Index: patches/patch-testsuite_Makefile_in === RCS file: patches/patch-tests
Re: [UPDATE] textproc/pdfgrep
One test still fails for me: Running ./pdfgrep.tests/regex.exp ... FAIL: Empty pattern -- error from pdfgrep Indeed, when pdfgrep is called with argument "", instead of matching every line it exits with error pdfgrep: empty (sub)expression This happens because our regex(3) doesn't allow empty patterns. As far as I can tell, this behavior is undesirable in something called "*grep", so I added a quirk for this particular use case. Other comments: In Makefile: > -MODULES =gcc4 > -MODGCC4_ARCHS = * > -MODGCC4_LANGS = c++ > +MODULES = gcc4 > +MODGCC4_ARCHS = * > +MODGCC4_LANGS = c++ Whitespace change. Why? > +TEST_DEPENDS = devel/dejagnu print/texlive/base Again, expanded space. In patches/patch-src-pdfgrep.cc: | +if (pledge("stdio rpath ioctl", NULL) == -1) { | + fprintf ( stderr, "pdfgrep: pledge\n" ); | + exit ( 1 ); | +} | + [...] | + | +if (pledge("stdio rpath", NULL) == -1) { | + fprintf ( stderr, "pdfgrep: pledge\n" ); | + exit ( 1 ); | +} I don't see a point in first pledge. As a matter of fact, I wouldn't pledge this port unless upstream is ready to accept pledge. And upstream will definitely not accept pledge without #ifdef. In patches/patch-testsuite-lib-pdfgrep.exp: | -set pdfdir [exec mktemp --tmpdir -d pdfgrep_tests.XX] | +set pdfdir [exec mktemp -d /tmp/pdfgrep_tests.XX] I'd use "mktemp -td pdfgrep_tests.XX]": this form still allows altering temporary directory, and upstream may want to use portable syntax. Patch with my corrections follow. I left second pledge in case people want it, although it will take much more work to make this patch upstreamable. -- Dmitrij D. Czarkoff --- Makefile.orig Tue Aug 25 18:28:04 2015 +++ MakefileFri Jan 15 12:28:50 2016 @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.3 2015/08/25 16:28:04 jca Exp $ +# $OpenBSD: Makefile,v 1.4 2015/08/25 16:28:04 jca Exp $ COMMENT = tool to search text in PDF files -DISTNAME = pdfgrep-1.4.0 +DISTNAME = pdfgrep-1.4.1 CATEGORIES = textproc @@ -17,11 +17,12 @@ MODGCC4_ARCHS =* MODGCC4_LANGS =c++ -WANTLIB += c m pthread stdc++ poppler-cpp pcre +WANTLIB += c m pthread poppler-cpp pcre MASTER_SITES = https://pdfgrep.org/download/ LIB_DEPENDS = print/poppler +TEST_DEPENDS = devel/dejagnu print/texlive/base CONFIGURE_ENV =LDFLAGS="-L${X11BASE}/lib" CONFIGURE_STYLE = gnu --- distinfo.orig Tue Aug 25 18:28:04 2015 +++ distinfoFri Jan 15 10:35:39 2016 @@ -1,2 +1,2 @@ -SHA256 (pdfgrep-1.4.0.tar.gz) = MwwRG5GpIRbVpnZsGx0i3NeVkonXNHHZNEsLBHX8quI= -SIZE (pdfgrep-1.4.0.tar.gz) = 125269 +SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw= +SIZE (pdfgrep-1.4.1.tar.gz) = 151926 --- patches/patch-src_pdfgrep_cc.orig Fri Jan 15 13:19:30 2016 +++ patches/patch-src_pdfgrep_ccFri Jan 15 12:44:28 2016 @@ -0,0 +1,15 @@ +$OpenBSD$ +--- src/pdfgrep.cc.origWed Sep 16 22:06:49 2015 src/pdfgrep.cc Fri Jan 15 12:29:06 2016 +@@ -775,6 +775,11 @@ int main(int argc, char** argv) + context = -1; + } + ++ if (pledge("stdio rpath", NULL) == -1) { ++ fprintf(stderr, "pdfgrep: pledge\n"); ++ exit(1); ++ } ++ + if (excludes_empty(includes)) + exclude_add(includes, "*.pdf"); + --- patches/patch-src_regengine_cc.orig Fri Jan 15 13:19:30 2016 +++ patches/patch-src_regengine_cc Fri Jan 15 13:07:54 2016 @@ -0,0 +1,13 @@ +$OpenBSD$ +--- src/regengine.cc.orig Fri Jan 15 13:06:26 2016 src/regengine.cc Fri Jan 15 13:07:45 2016 +@@ -34,6 +34,9 @@ PosixRegex::PosixRegex(const char *pattern, bool case_ + { + int regex_flags = REG_EXTENDED | (case_insensitive ? REG_ICASE : 0); + ++ if (strncmp(pattern, "", 2) == 0) { ++ pattern = "()"; ++ } + int err = regcomp(&this->regex, pattern, regex_flags); + if(err) { + char err_msg[256]; --- patches/patch-testsuite_Makefile_in.origFri Jan 15 13:19:30 2016 +++ patches/patch-testsuite_Makefile_in Fri Jan 15 13:19:11 2016 @@ -0,0 +1,14 @@ +$OpenBSD$ +--- testsuite/Makefile.in.orig Thu Sep 24 21:32:33 2015 testsuite/Makefile.in Fri Jan 15 13:18:59 2016 +@@ -641,10 +641,3 @@ uninstall-am: + tags-am uninstall uninstall-am + + .PRECIOUS: Makefile +- +- +-export DEJAGNU +- +-# Tell versions [3.59,3.63) of GNU make to not export all variables. +-# Otherwise a system limit (for SysV at least) may be exceeded. +-.NOEXPORT: --- patches/patch-testsuite_lib_pdfgrep_exp.origFri Jan 15 13:19:30 2016 +++ patches/patch-testsuite_lib_pdfgrep_exp Fri Jan 15 11:12:21 2016 @@ -0,0 +1,12 @@ +$OpenBSD$ +--- testsuite/lib/pdfgrep.exp.
Re: [UPDATE] textproc/pdfgrep
> + int main(int argc, char** argv) > + { > ++if (pledge("stdio rpath ioctl", NULL) == -1) { > ++fprintf ( stderr, "pdfgrep: pledge\n" ); > ++exit ( 1 ); > ++} This ioctl pledge feels wrong. I only have a lousy internet connection and no gcc 4.9 installed, so I can't really test. The source shows only a TIOCGWINSZ ioctl, which is covered by pledge "tty" which makes much more sense to me.
Re: [UPDATE] textproc/pdfgrep
On 2016/01/15 13:36, Theo Buehler wrote: > > + int main(int argc, char** argv) > > + { > > ++ if (pledge("stdio rpath ioctl", NULL) == -1) { > > ++ fprintf ( stderr, "pdfgrep: pledge\n" ); > > ++ exit ( 1 ); > > ++ } > > This ioctl pledge feels wrong. I only have a lousy internet connection > and no gcc 4.9 installed, so I can't really test. The source shows only > a TIOCGWINSZ ioctl, which is covered by pledge "tty" which makes much > more sense to me. > Ah yes you are right. I've adjusted it in my tree.
Re: [UPDATE] textproc/pdfgrep
On 2016/01/15 13:21, Dmitrij D. Czarkoff wrote: > This happens because our regex(3) doesn't allow empty patterns. As far > as I can tell, this behavior is undesirable in something called "*grep", > so I added a quirk for this particular use case. Agreed.
Re: [UPDATE] textproc/pdfgrep
Stuart Henderson said: > On 2016/01/15 13:36, Theo Buehler wrote: > > > + int main(int argc, char** argv) > > > + { > > > ++if (pledge("stdio rpath ioctl", NULL) == -1) { > > > ++fprintf ( stderr, "pdfgrep: pledge\n" ); > > > ++exit ( 1 ); > > > ++} > > > > This ioctl pledge feels wrong. I only have a lousy internet connection > > and no gcc 4.9 installed, so I can't really test. The source shows only > > a TIOCGWINSZ ioctl, which is covered by pledge "tty" which makes much > > more sense to me. > > > > Ah yes you are right. I've adjusted it in my tree. What is the point of this first pledge call? -- Dmitrij D. Czarkoff
Re: [UPDATE] textproc/pdfgrep
On 2016/01/15 14:42, Dmitrij D. Czarkoff wrote: > Stuart Henderson said: > > On 2016/01/15 13:36, Theo Buehler wrote: > > > > + int main(int argc, char** argv) > > > > + { > > > > ++ if (pledge("stdio rpath ioctl", NULL) == -1) { > > > > ++ fprintf ( stderr, "pdfgrep: pledge\n" ); > > > > ++ exit ( 1 ); > > > > ++ } > > > > > > This ioctl pledge feels wrong. I only have a lousy internet connection > > > and no gcc 4.9 installed, so I can't really test. The source shows only > > > a TIOCGWINSZ ioctl, which is covered by pledge "tty" which makes much > > > more sense to me. > > > > > > > Ah yes you are right. I've adjusted it in my tree. > > What is the point of this first pledge call? It means that the list of available system calls is cut right down before the first function calls into PCRE and Poppler, which I think is nice to have. I'm pleased to see that Poppler doesn't seem to be having problems running with pledge for basic use. Hopefully this can be pushed out into a full PDF viewer.
Re: [UPDATE] textproc/pdfgrep
ok? On 06.03.17 18:18, Reinhold Straub wrote: Hi all, pdfgrep has been updated to v. 2.0.1 It has a new option: --cache, which needs additional dependencies and some modification to the pledge(2) syscalls. Most of our previous patches have been accepted upstream. Regards, Reinhold Straub Index: pdfgrep/Makefile === RCS file: /cvs/ports/textproc/pdfgrep/Makefile,v retrieving revision 1.5 diff -u -p -u -r1.5 Makefile --- pdfgrep/Makefile15 Jan 2016 19:57:24 - 1.5 +++ pdfgrep/Makefile6 Mar 2017 16:52:57 - @@ -2,7 +2,7 @@ COMMENT = tool to search text in PDF files -DISTNAME = pdfgrep-1.4.1 +DISTNAME = pdfgrep-2.0.1 CATEGORIES = textproc @@ -18,11 +18,12 @@ MODGCC4_ARCHS = * MODGCC4_LANGS =c++ # uses pledge() -WANTLIB += c m pthread poppler-cpp pcre +WANTLIB += c m pthread poppler-cpp pcre gcrypt gpg-error MASTER_SITES = https://pdfgrep.org/download/ -LIB_DEPENDS = print/poppler +LIB_DEPENDS = print/poppler \ + security/libgcrypt TEST_DEPENDS = devel/dejagnu \ print/texlive/base Index: pdfgrep/distinfo === RCS file: /cvs/ports/textproc/pdfgrep/distinfo,v retrieving revision 1.3 diff -u -p -u -r1.3 distinfo --- pdfgrep/distinfo15 Jan 2016 19:42:40 - 1.3 +++ pdfgrep/distinfo6 Mar 2017 16:52:57 - @@ -1,2 +1,2 @@ -SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw= -SIZE (pdfgrep-1.4.1.tar.gz) = 151926 +SHA256 (pdfgrep-2.0.1.tar.gz) = A3DXRLMHLUc4Pb7Sy5yLC2S4PAhNpaiWH41Lx2aelB4= +SIZE (pdfgrep-2.0.1.tar.gz) = 187217 patches.tar.gz Description: GNU Zip compressed data
Re: [UPDATE] textproc/pdfgrep
On Tue, Mar 14, 2017 at 09:35:37AM +0100, Reinhold Straub wrote: > ok? > > On 06.03.17 18:18, Reinhold Straub wrote: > > Hi all, > > > > pdfgrep has been updated to v. 2.0.1 > > > > It has a new option: --cache, which needs additional dependencies and some > > modification to the pledge(2) syscalls. > > > > Most of our previous patches have been accepted upstream. Thanks. Your patch didn't apply cleanly, so I regenerated it, see below. Apply with 'patch -E'. Your diff looks good and the port builds fine and all tests pass. However, I ran into the following problem with any pdf file: $ LC_CTYPE=en_US.UTF-8 pdfgrep RFC /tmp/slides.pdf terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid Abort trap (core dumped) This is new, the old port works fine in the UTF-8 locale. Unsurprisingly, the problem is the locale call in src/pdfgrep.cc 434 // Set locale to user-preference. If this locale is an UTF-8 locale, the 435 // regex-functions regcomp/regexec become unicode aware, which means 436 // e.g. that '.' will match a unicode character, not a single byte. 437 locale::global(locale("")); commenting it out works around the problem. I have no idea what the proper fix is. FWIW here's the backtrace which isn't that useful thanks to the Dwarf Error: (gdb) bt #0 0x069bf4e4dd2a in thrkill () at :2 #1 0x069bf4e608f9 in *_libc_abort () at /usr/src/lib/libc/stdlib/abort.c:52 #2 0x069bf87feef5 in __gnu_cxx::__verbose_terminate_handler () at /usr/obj/ports/gcc-4.9.4/gcc-4.9.4/libstdc++-v3/libsupc++/vterminate.cc:95 Die: DW_TAG_unspecified_type (abbrev = 26, offset = 139365) has children: FALSE attributes: DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)" Dwarf Error: Cannot find type of die [in module /usr/local/lib/libestdc++.so.17.0] Index: Makefile === RCS file: /var/cvs/ports/textproc/pdfgrep/Makefile,v retrieving revision 1.5 diff -u -p -r1.5 Makefile --- Makefile15 Jan 2016 19:57:24 - 1.5 +++ Makefile14 Mar 2017 09:37:14 - @@ -2,7 +2,7 @@ COMMENT = tool to search text in PDF files -DISTNAME = pdfgrep-1.4.1 +DISTNAME = pdfgrep-2.0.1 CATEGORIES = textproc @@ -18,11 +18,12 @@ MODGCC4_ARCHS = * MODGCC4_LANGS =c++ # uses pledge() -WANTLIB += c m pthread poppler-cpp pcre +WANTLIB += c m pthread poppler-cpp pcre gcrypt gpg-error MASTER_SITES = https://pdfgrep.org/download/ -LIB_DEPENDS = print/poppler +LIB_DEPENDS = print/poppler \ + security/libgcrypt TEST_DEPENDS = devel/dejagnu \ print/texlive/base Index: distinfo === RCS file: /var/cvs/ports/textproc/pdfgrep/distinfo,v retrieving revision 1.3 diff -u -p -r1.3 distinfo --- distinfo15 Jan 2016 19:42:40 - 1.3 +++ distinfo14 Mar 2017 09:34:21 - @@ -1,2 +1,2 @@ -SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw= -SIZE (pdfgrep-1.4.1.tar.gz) = 151926 +SHA256 (pdfgrep-2.0.1.tar.gz) = A3DXRLMHLUc4Pb7Sy5yLC2S4PAhNpaiWH41Lx2aelB4= +SIZE (pdfgrep-2.0.1.tar.gz) = 187217 Index: patches/patch-src_pdfgrep_cc === RCS file: /var/cvs/ports/textproc/pdfgrep/patches/patch-src_pdfgrep_cc,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_pdfgrep_cc --- patches/patch-src_pdfgrep_cc15 Jan 2016 19:42:40 - 1.1 +++ patches/patch-src_pdfgrep_cc14 Mar 2017 10:32:18 - @@ -1,27 +1,40 @@ -$OpenBSD: patch-src_pdfgrep_cc,v 1.1 2016/01/15 19:42:40 sthen Exp $ src/pdfgrep.cc.origWed Sep 16 21:06:49 2015 -+++ src/pdfgrep.cc Fri Jan 15 11:39:19 2016 -@@ -569,6 +569,11 @@ void handle_poppler_errors(const std::string &msg, voi - +$OpenBSD$ +--- src/pdfgrep.cc.origSat Mar 4 09:11:53 2017 src/pdfgrep.cc Tue Mar 14 11:32:03 2017 +@@ -423,6 +423,12 @@ static void handle_poppler_errors(const string &msg, v int main(int argc, char** argv) { -+ if (pledge("stdio rpath tty", NULL) == -1) { + Options options; ++ ++ if (pledge("stdio rpath wpath cpath tty", NULL) == -1) { + fprintf (stderr, "pdfgrep: pledge\n"); + exit (1); + } + - init_colors(); + init_colors(options.outconf.colors); - enum re_engine_type { -@@ -773,6 +778,11 @@ int main(int argc, char** argv) - } else if (context == -2) { - // on non-terminals, always print the whole line - context = -1; -+ } -+ -+ if (pledge("stdio rpath", NULL) == -1) { + // Set locale to user-preference. If this locale is an UTF-8 locale, the +@@ -
Re: [UPDATE] textproc/pdfgrep
Theo Buehler writes: > On Tue, Mar 14, 2017 at 09:35:37AM +0100, Reinhold Straub wrote: >> ok? >> >> On 06.03.17 18:18, Reinhold Straub wrote: >> > Hi all, >> > >> > pdfgrep has been updated to v. 2.0.1 >> > >> > It has a new option: --cache, which needs additional dependencies and some >> > modification to the pledge(2) syscalls. >> > >> > Most of our previous patches have been accepted upstream. > > Thanks. Your patch didn't apply cleanly, so I regenerated it, see below. > Apply with 'patch -E'. > > Your diff looks good and the port builds fine and all tests pass. > However, I ran into the following problem with any pdf file: > > $ LC_CTYPE=en_US.UTF-8 pdfgrep RFC /tmp/slides.pdf > terminate called after throwing an instance of 'std::runtime_error' > what(): locale::facet::_S_create_c_locale name not valid > Abort trap (core dumped) > > This is new, the old port works fine in the UTF-8 locale. > > Unsurprisingly, the problem is the locale call in src/pdfgrep.cc > >434// Set locale to user-preference. If this locale is an > UTF-8 locale, the >435// regex-functions regcomp/regexec become unicode > aware, which means >436// e.g. that '.' will match a unicode character, not a > single byte. >437locale::global(locale("")); > > commenting it out works around the problem. I have no idea what the > proper fix is. I don't think a proper fix is possible. I had suggested a "fix" for libstdc++v3 in base. http://marc.info/?l=openbsd-ports&m=148154492428992&w=2 Maybe silencing this assertion in libestdc++ is the sanest way to deal with this. Or you could just comment the call to locale::global(locale("")); Our locale support is limited anyway... > FWIW here's the backtrace which isn't that useful thanks to the Dwarf > Error: egdb should perform better. > (gdb) bt > #0 0x069bf4e4dd2a in thrkill () at :2 > #1 0x069bf4e608f9 in *_libc_abort () at > /usr/src/lib/libc/stdlib/abort.c:52 > #2 0x069bf87feef5 in __gnu_cxx::__verbose_terminate_handler () > at > /usr/obj/ports/gcc-4.9.4/gcc-4.9.4/libstdc++-v3/libsupc++/vterminate.cc:95 > Die: DW_TAG_unspecified_type (abbrev = 26, offset = 139365) > has children: FALSE > attributes: > DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)" > Dwarf Error: Cannot find type of die [in module > /usr/local/lib/libestdc++.so.17.0] > > Index: Makefile > === > RCS file: /var/cvs/ports/textproc/pdfgrep/Makefile,v > retrieving revision 1.5 > diff -u -p -r1.5 Makefile > --- Makefile 15 Jan 2016 19:57:24 - 1.5 > +++ Makefile 14 Mar 2017 09:37:14 - > @@ -2,7 +2,7 @@ > > COMMENT =tool to search text in PDF files > > -DISTNAME = pdfgrep-1.4.1 > +DISTNAME = pdfgrep-2.0.1 > > CATEGORIES = textproc > > @@ -18,11 +18,12 @@ MODGCC4_ARCHS = * > MODGCC4_LANGS = c++ > > # uses pledge() > -WANTLIB += c m pthread poppler-cpp pcre > +WANTLIB += c m pthread poppler-cpp pcre gcrypt gpg-error > > MASTER_SITES = https://pdfgrep.org/download/ > > -LIB_DEPENDS =print/poppler > +LIB_DEPENDS =print/poppler \ > + security/libgcrypt > TEST_DEPENDS = devel/dejagnu \ > print/texlive/base > > Index: distinfo > === > RCS file: /var/cvs/ports/textproc/pdfgrep/distinfo,v > retrieving revision 1.3 > diff -u -p -r1.3 distinfo > --- distinfo 15 Jan 2016 19:42:40 - 1.3 > +++ distinfo 14 Mar 2017 09:34:21 - > @@ -1,2 +1,2 @@ > -SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw= > -SIZE (pdfgrep-1.4.1.tar.gz) = 151926 > +SHA256 (pdfgrep-2.0.1.tar.gz) = A3DXRLMHLUc4Pb7Sy5yLC2S4PAhNpaiWH41Lx2aelB4= > +SIZE (pdfgrep-2.0.1.tar.gz) = 187217 > Index: patches/patch-src_pdfgrep_cc > === > RCS file: /var/cvs/ports/textproc/pdfgrep/patches/patch-src_pdfgrep_cc,v > retrieving revision 1.1 > diff -u -p -r1.1 patch-src_pdfgrep_cc > --- patches/patch-src_pdfgrep_cc 15 Jan 2016 19:42:40 - 1.1 > +++ patches/patch-src_pdfgrep_cc 14 Mar 2017 10:32:18 - > @@ -1,27 +1,40 @@ > -$OpenBSD: patch-src_pdfgrep_cc,v 1.1 2016/01/15 19:42:40 sthen Exp $ > src/pdfgrep.cc.orig Wed Sep 16 21:06:49 2015 > -+++ src/pdfgrep.cc Fri Jan 15 11:39:19 2016 > -@@ -569,6 +569,11 @@ void handle_poppler_errors(const std::string &msg, voi > - > +$OpenBSD$ > +--- src/pdfgrep.cc.orig Sat Mar 4 09:11:53 2017 > src/pdfgrep.cc Tue Mar 14 11:32:03 2017 > +@@ -423,6 +423,12 @@ static void handle_poppler_errors(const string &msg, v > int main(int argc, char** argv) > { > -+if (pledge("stdio rpath tty", NULL) == -1) { > +
Re: [UPDATE] textproc/pdfgrep
On Tue, Mar 14, 2017 at 12:14:42PM +0100, Jeremie Courreges-Anglas wrote: > Theo Buehler writes: > > > On Tue, Mar 14, 2017 at 09:35:37AM +0100, Reinhold Straub wrote: > >> ok? > >> > >> On 06.03.17 18:18, Reinhold Straub wrote: > >> > Hi all, > >> > > >> > pdfgrep has been updated to v. 2.0.1 > >> > > >> > It has a new option: --cache, which needs additional dependencies and > >> > some modification to the pledge(2) syscalls. > >> > > >> > Most of our previous patches have been accepted upstream. > > > > Thanks. Your patch didn't apply cleanly, so I regenerated it, see below. > > Apply with 'patch -E'. > > > > Your diff looks good and the port builds fine and all tests pass. > > However, I ran into the following problem with any pdf file: > > > > $ LC_CTYPE=en_US.UTF-8 pdfgrep RFC /tmp/slides.pdf > > terminate called after throwing an instance of 'std::runtime_error' > > what(): locale::facet::_S_create_c_locale name not valid > > Abort trap (core dumped) > > > > This is new, the old port works fine in the UTF-8 locale. > > > > Unsurprisingly, the problem is the locale call in src/pdfgrep.cc > > > >434 // Set locale to user-preference. If this locale is an > > UTF-8 locale, the > >435 // regex-functions regcomp/regexec become unicode > > aware, which means > >436 // e.g. that '.' will match a unicode character, not a > > single byte. > >437 locale::global(locale("")); > > > > commenting it out works around the problem. I have no idea what the > > proper fix is. > > I don't think a proper fix is possible. I had suggested a "fix" for > libstdc++v3 in base. > > http://marc.info/?l=openbsd-ports&m=148154492428992&w=2 > > Maybe silencing this assertion in libestdc++ is the sanest way to deal > with this. Or you could just comment the call to > > locale::global(locale("")); > > Our locale support is limited anyway... > Alright, thanks. As I said previously, commenting this out works. This is pretty disgusting. I don't really know how badly pcre will react to this, but I guess it can't be worse than the segfault. The cure that worked in the other thread (using gcc4) obviously won't help here, so here's the diff with the line commented. Index: Makefile === RCS file: /var/cvs/ports/textproc/pdfgrep/Makefile,v retrieving revision 1.5 diff -u -p -r1.5 Makefile --- Makefile15 Jan 2016 19:57:24 - 1.5 +++ Makefile14 Mar 2017 21:09:20 - @@ -2,7 +2,7 @@ COMMENT = tool to search text in PDF files -DISTNAME = pdfgrep-1.4.1 +DISTNAME = pdfgrep-2.0.1 CATEGORIES = textproc @@ -18,11 +18,12 @@ MODGCC4_ARCHS = * MODGCC4_LANGS =c++ # uses pledge() -WANTLIB += c m pthread poppler-cpp pcre +WANTLIB += c m pthread poppler-cpp pcre gcrypt gpg-error MASTER_SITES = https://pdfgrep.org/download/ -LIB_DEPENDS = print/poppler +LIB_DEPENDS = print/poppler \ + security/libgcrypt TEST_DEPENDS = devel/dejagnu \ print/texlive/base Index: distinfo === RCS file: /var/cvs/ports/textproc/pdfgrep/distinfo,v retrieving revision 1.3 diff -u -p -r1.3 distinfo --- distinfo15 Jan 2016 19:42:40 - 1.3 +++ distinfo14 Mar 2017 09:34:21 - @@ -1,2 +1,2 @@ -SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw= -SIZE (pdfgrep-1.4.1.tar.gz) = 151926 +SHA256 (pdfgrep-2.0.1.tar.gz) = A3DXRLMHLUc4Pb7Sy5yLC2S4PAhNpaiWH41Lx2aelB4= +SIZE (pdfgrep-2.0.1.tar.gz) = 187217 Index: patches/patch-src_pdfgrep_cc === RCS file: /var/cvs/ports/textproc/pdfgrep/patches/patch-src_pdfgrep_cc,v retrieving revision 1.1 diff -u -p -r1.1 patch-src_pdfgrep_cc --- patches/patch-src_pdfgrep_cc15 Jan 2016 19:42:40 - 1.1 +++ patches/patch-src_pdfgrep_cc14 Mar 2017 21:08:31 - @@ -1,27 +1,49 @@ -$OpenBSD: patch-src_pdfgrep_cc,v 1.1 2016/01/15 19:42:40 sthen Exp $ src/pdfgrep.cc.origWed Sep 16 21:06:49 2015 -+++ src/pdfgrep.cc Fri Jan 15 11:39:19 2016 -@@ -569,6 +569,11 @@ void handle_poppler_errors(const std::string &msg, voi - +$OpenBSD$ + +disable locale::global(locale("")) to avoid a segfault in the UTF-8 locale. +--- src/pdfgrep.cc.origSat Mar 4 09:11:53 2017 src/pdfgrep.cc Tue Mar 14 22:07:41 2017 +@@ -423,12 +423,18 @@ static void handle_poppler_errors(const string &msg, v int main(int argc, char** argv) { -+ if (pledge("stdio rpath tty", NULL) == -1) { + Options options; ++ ++ if (pledge("stdio rpath wpath cpath tty", NULL) == -1) { + fprintf (stderr, "pdfgrep: pledge\n"); + exit (1); + } + - init_colors(); + in
Re: [UPDATE] textproc/pdfgrep
How about killing the wpath pledge if --cache is not used? I was a bit confused as to why it needs gcrypt for a caching option... turns out it uses it to SHA1 the contents of the pdf.
Re: [UPDATE] textproc/pdfgrep
On Tue, Mar 14, 2017 at 09:29:48PM +, Stuart Henderson wrote: > How about killing the wpath pledge if --cache is not used? > It already does that. It's not visible in the diff, but we have: 694 if (options.use_cache) { [...] 704 } else { 705 if (pledge("stdio rpath", NULL) == -1) { 706 fprintf (stderr, "pdfgrep: pledge\n"); 707 exit (1); 708 } 709 }
Re: [UPDATE] textproc/pdfgrep
Theo Buehler writes: > On Tue, Mar 14, 2017 at 12:14:42PM +0100, Jeremie Courreges-Anglas wrote: >> Theo Buehler writes: >> >> > On Tue, Mar 14, 2017 at 09:35:37AM +0100, Reinhold Straub wrote: >> >> ok? >> >> >> >> On 06.03.17 18:18, Reinhold Straub wrote: >> >> > Hi all, >> >> > >> >> > pdfgrep has been updated to v. 2.0.1 >> >> > >> >> > It has a new option: --cache, which needs additional dependencies and >> >> > some modification to the pledge(2) syscalls. >> >> > >> >> > Most of our previous patches have been accepted upstream. >> > >> > Thanks. Your patch didn't apply cleanly, so I regenerated it, see below. >> > Apply with 'patch -E'. >> > >> > Your diff looks good and the port builds fine and all tests pass. >> > However, I ran into the following problem with any pdf file: >> > >> > $ LC_CTYPE=en_US.UTF-8 pdfgrep RFC /tmp/slides.pdf >> > terminate called after throwing an instance of 'std::runtime_error' >> > what(): locale::facet::_S_create_c_locale name not valid >> > Abort trap (core dumped) >> > >> > This is new, the old port works fine in the UTF-8 locale. >> > >> > Unsurprisingly, the problem is the locale call in src/pdfgrep.cc >> > >> >434 // Set locale to user-preference. If this locale is an >> > UTF-8 locale, the >> >435 // regex-functions regcomp/regexec become unicode >> > aware, which means >> >436 // e.g. that '.' will match a unicode character, not a >> > single byte. >> >437 locale::global(locale("")); >> > >> > commenting it out works around the problem. I have no idea what the >> > proper fix is. >> >> I don't think a proper fix is possible. I had suggested a "fix" for >> libstdc++v3 in base. >> >> http://marc.info/?l=openbsd-ports&m=148154492428992&w=2 >> >> Maybe silencing this assertion in libestdc++ is the sanest way to deal >> with this. Or you could just comment the call to >> >> locale::global(locale("")); >> >> Our locale support is limited anyway... >> > > Alright, thanks. As I said previously, commenting this out works. Ah, indeed, I read you too fast. > This > is pretty disgusting. I don't really know how badly pcre will react to > this, but I guess it can't be worse than the segfault. Are you thinking about regexec/regcomp (the default, IIUC) or about pcre (-P)? pcre seems to respect my UTF-8 locale, regcomp/regexec don't, even if I add a setlocale(LC_ALL, "") call. > The cure that worked in the other thread (using gcc4) obviously won't > help here, so here's the diff with the line commented. The update seems to work fine here, ok jca@ > Index: Makefile > === > RCS file: /var/cvs/ports/textproc/pdfgrep/Makefile,v > retrieving revision 1.5 > diff -u -p -r1.5 Makefile > --- Makefile 15 Jan 2016 19:57:24 - 1.5 > +++ Makefile 14 Mar 2017 21:09:20 - > @@ -2,7 +2,7 @@ > > COMMENT =tool to search text in PDF files > > -DISTNAME = pdfgrep-1.4.1 > +DISTNAME = pdfgrep-2.0.1 > > CATEGORIES = textproc > > @@ -18,11 +18,12 @@ MODGCC4_ARCHS = * > MODGCC4_LANGS = c++ > > # uses pledge() > -WANTLIB += c m pthread poppler-cpp pcre > +WANTLIB += c m pthread poppler-cpp pcre gcrypt gpg-error > > MASTER_SITES = https://pdfgrep.org/download/ > > -LIB_DEPENDS =print/poppler > +LIB_DEPENDS =print/poppler \ > + security/libgcrypt > TEST_DEPENDS = devel/dejagnu \ > print/texlive/base > > Index: distinfo > === > RCS file: /var/cvs/ports/textproc/pdfgrep/distinfo,v > retrieving revision 1.3 > diff -u -p -r1.3 distinfo > --- distinfo 15 Jan 2016 19:42:40 - 1.3 > +++ distinfo 14 Mar 2017 09:34:21 - > @@ -1,2 +1,2 @@ > -SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw= > -SIZE (pdfgrep-1.4.1.tar.gz) = 151926 > +SHA256 (pdfgrep-2.0.1.tar.gz) = A3DXRLMHLUc4Pb7Sy5yLC2S4PAhNpaiWH41Lx2aelB4= > +SIZE (pdfgrep-2.0.1.tar.gz) = 187217 > Index: patches/patch-src_pdfgrep_cc > === > RCS file: /var/cvs/ports/textproc/pdfgrep/patches/patch-src_pdfgrep_cc,v > retrieving revision 1.1 > diff -u -p -r1.1 patch-src_pdfgrep_cc > --- patches/patch-src_pdfgrep_cc 15 Jan 2016 19:42:40 - 1.1 > +++ patches/patch-src_pdfgrep_cc 14 Mar 2017 21:08:31 - > @@ -1,27 +1,49 @@ > -$OpenBSD: patch-src_pdfgrep_cc,v 1.1 2016/01/15 19:42:40 sthen Exp $ > src/pdfgrep.cc.orig Wed Sep 16 21:06:49 2015 > -+++ src/pdfgrep.cc Fri Jan 15 11:39:19 2016 > -@@ -569,6 +569,11 @@ void handle_poppler_errors(const std::string &msg, voi > - > +$OpenBSD$ > + > +disable locale::global(locale("")) to avoid a segfault in the UTF-8 locale. > +--- src/pdfgrep.cc.orig Sat
Re: [UPDATE] textproc/pdfgrep
On Mon, Mar 06, 2017 at 06:18:15PM +0100, Reinhold Straub wrote: > Hi all, > > pdfgrep has been updated to v. 2.0.1 > > It has a new option: --cache, which needs additional dependencies and some > modification to the pledge(2) syscalls. > > Most of our previous patches have been accepted upstream. Thanks, it is now committed with the changes discussed in the thread.