racket-poppler dumping core & failing contract checks

25 views
Skip to first unread message

'John Clements' via users-redirect

unread,
Feb 20, 2020, 5:04:45 PM2/20/20
to Jens Axel Søgaard, Racket Users
I’m interested in converting TeX to picts. It looks like racket-poppler might be the way to do that.

Unfortunately, I’m having trouble running racket-poppler. I ran into several problems, but fortunately, all of the problems that I saw were also observed by the test suite. Running

raco test -p racket-poppler

on my machine (macOS 10.15.2, racket built from git source this morning) produces both a contract failure and a core dump. (Transcript below.)

One obvious problem is that it looks like the latex->pict function now requires a #:preamble keyword, which apparently the tests don’t expect? Also, I’m dumping core in the ffi calls. What’s the right way to fix this?

Thanks!

John Clements



ardy:/tmp clements> raco test -p racket-poppler
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/info.rkt"
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt"
#t
#<pdf>
""
'((title "") (author "") (aubject "") (keywords "") (creator "LaTeX with hyperref package") (producer "pdfTeX-1.40.3") (page-count 364))
#<page>
'(612.0 792.0)
'(0.0 0.0 612.0 792.0)
"The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket or new to some part of\nRacket. It assumes programming experience, so if you are new to programming, consider\ninstead reading How to Design Programs. If you want an especially quick introduction to\nRacket, start with Quick: An Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of the Racket toolbox, but leaving precise details to The Racket\nReference and other reference manuals."
"The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket or new to some part of\nRacket. It assumes programming experience, so if you are new to programming, consider\ninstead reading How to Design Programs. If you want an especially quick introduction to\nRacket, start with Quick: An Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of the Racket toolbox, but leaving precise details to The Racket\nReference and other reference manuals.\n1"
'()
'((238.76 164.72937400000006 250.24267179999998 180.20601860000005) (250.24267179999998 164.72937400000006 259.8144342 180.20601860000005) (259.8144342 164.72937400000006 267.45807179999997 180.20601860000005) (267.45807179999997 164.72937400000006 271.7619218 180.20601860000005) (271.7619218 164.72937400000006 284.19144059999996 180.20601860000005))
Assertion failed: (! scaled_font->cache_frozen), function cairo_scaled_font_create, file cairo-scaled-font.c, line 1175.
test-pdf-functions.rkt: raco test: non-zero exit: 134
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/examples/test-render-tex.rkt"
application: required keyword argument not supplied
procedure: latex->pict
required keyword: #:preamble
arguments...:
"$\\sqrt{x^2+y^2}$"
context...:
/Users/clements/racket/racket/collects/racket/private/kw.rkt:1544:14
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/examples/test-render-tex.rkt": [running body]
temp35_0
for-loop
run-module-instance!
(submod "/Users/clements/racket/pkgs/compiler-lib/compiler/commands/test.rkt" process): [running body]
temp35_0
for-loop
run-module-instance!
eval-one-top
test-render-tex.rkt: raco test: non-zero exit: 1
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/ffi.rkt"
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/info.rkt"
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/libs.rkt"
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/main.rkt"
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/render-tex.rkt"
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/test-render-tex.rkt"
application: required keyword argument not supplied
procedure: latex->pict
required keyword: #:preamble
arguments...:
"$\\sqrt{x^2+y^2+z}$"
context...:
/Users/clements/racket/racket/collects/racket/private/kw.rkt:1544:14
"/Users/clements/racket/racket/share/pkgs/racket-poppler/test-render-tex.rkt": [running body]
temp35_0
for-loop
run-module-instance!
(submod "/Users/clements/racket/pkgs/compiler-lib/compiler/commands/test.rkt" process): [running body]
temp35_0
for-loop
run-module-instance!
eval-one-top
test-render-tex.rkt: raco test: non-zero exit: 1
3/3 test failures
hardy:/tmp clements>



'John Clements' via users-redirect

unread,
Feb 20, 2020, 7:26:22 PM2/20/20
to Jens Axel Søgaard, Racket Users
Forwarding this with permission to the kind folks on racket-users…

I’m having a strange problem with raco test; specifically, performing raco test on a file in a collection from the racket-poppler collection generates error text very fast… about 3 megabytes per second… with this text (apparently) repeated ad infinitum:

> > internal error: attempt to deschedule the current thread in atomic mode
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: internal error: attempt to deschedule the current thread in atomic mode
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > l
> > loop
> > dynamic-wind
> > temp52_0
> > .../ffi/unsafe.rkt:2117:27: loop
> > .../private/more-scheme.rkt:265:2: call-with-exception-handler
> > call-in-empty-metacontinuation-frame
> > .../ffi/unsafe.rkt:2104:19: retry-loop
> > call-in-empty-metacontinuation-frame
> > call-with-empty-metacontinuation-frame-for-swap

(a longer prefix appears below)

However, copying the same file to /tmp/ and running raco test on that file produces much saner output (included below).

The bad news: this package uses ffi, so in some sense all bets are off.

The important question: is this difference likely to be the result of a “real" internal error in racket, and it would be a good idea to try and track it down, or is this a known problem with raco test, or something else entirely?

FWIW, this is stock 7.6, running on macOS 10.15.2.

Any thoughts welcome!

John

> On Feb 20, 2020, at 4:02 PM, Jens Axel Søgaard <jens...@soegaard.net> wrote:
>
> > BTW, is it okay with you if I forward this to racket-users? I feel like people there might be better able to answer some of these questions.
>
> Of course.
>
> I might have forgotten to try the examples when I updated racket-poppler to work with latex-pict.
>
> And I just notices that the docs of latex-pict is missing on docs.racket-lang.org.
> You hopefully found them in the source, but if not the beginning of
>
> https://github.com/soegaard/latex-pict/blob/master/latex-pict/tex.rkt
>
> contains an explanation.
>
> /Jens Axel
>
>
>
> Den fre. 21. feb. 2020 kl. 00.56 skrev John Clements <clem...@brinckerhoff.org>:
> Okay, that worked! Good to see.
>
> On the topic of the output explosion … I’m not sure exactly what’s going on. The problem appears to be related to the “test-pdf-functions.rkt” file, but when I run it directly, I get a different and more sensible error
>
> hardy:/tmp clements> /Applications/Racket\ v7.6/bin/racket /Users/clements/Library/Racket/7.6/pkgs/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt
> #f
> #f
> pdf-title: contract violation
> expected: pdf?
> given: #f
> in: the 1st argument of
> (-> pdf? (or/c false? string?))
> contract from:
> <pkgs>/racket-poppler/racket-poppler/main.rkt
> blaming: <pkgs>/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt
> (assuming the contract is correct)
> at: <pkgs>/racket-poppler/racket-poppler/main.rkt:42.2
> context...:
> .../private/blame.rkt:347:0: raise-blame-error
> .../private/arrow-val-first.rkt:486:18
> call-with-values
> call-in-empty-metacontinuation-frame
> body of "/Users/clements/Library/Racket/7.6/pkgs/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt"
> temp35_0
> for-loop
> run-module-instance!
> perform-require!
> namespace-require+
> #%for-each
> call-in-empty-metacontinuation-frame
> [repeats 1 more time]
> call-with-empty-metacontinuation-frame-for-swap
>
> I’m not sure why calling it with raco test causes the explosion, especially since I don’t see any use of test-specific functions in this file.
>
> BTW, is it okay with you if I forward this to racket-users? I feel like people there might be better able to answer some of these questions.
>
> John
>
>
> > On Feb 20, 2020, at 3:41 PM, Jens Axel Søgaard <jens...@soegaard.net> wrote:
> >
> >
> > Den fre. 21. feb. 2020 kl. 00.35 skrev John Clements <clem...@brinckerhoff.org>:
> > Whoa!
> >
> > I just tried installing racket-poppler on my 7.6 installation, and tried running
> >
> > raco test -p racket-poppler
> >
> > and generated a LOT of error text very quickly. I redirected it to a file and it generated 95 Megabytes quite quickly. After the first few pages, though, you see a pattern.
> >
> > FWIW, this is on macOS 10.15.2.
> >
> > I see the same as you - but I don't know what that command is running.
> > I don't made any tests for racket-poppler?
> >
> > I just tried this program in DrRacket 7.6 CS
> >
> > #lang racket
> > (require racket-poppler latex-pict pict)
> > (pict->bitmap (tex-math "1+x"))
> >
> > and that worked fine.
> >
> > By the way - you might need to update to TexLive 2019 if you haven't already.
> >
> > pdflatex
> > This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex)
> > restricted \write18 enabled.
> >
> > /Jens Axel
> >
> >
> > Here’s the first few hundred lines.
> >
> >
> > hardy:/tmp clements> head -150 zz.txt
> > raco test: "/Users/clements/Library/Racket/7.6/pkgs/racket-poppler/info.rkt"
> > raco test: "/Users/clements/Library/Racket/7.6/pkgs/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt"
> > cpointer-ref: contract violation
> > expected: cpointer?
> > given: "The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket or new to some part of\nRacket. It assumes programming experience, so if you are new to programming, consider\ninstead reading How to Design Programs. If you want an especially quick introduction to\nRacket, start with Quick: An Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of the Racket toolbox, but leaving precise details to The Racket\nReference and other reference manuals.\n1"
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: cpointer-ref: contract violation
> > expected: cpointer?
> > given: "The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket or new to some part of\nRacket. It assumes programming experience, so if you are new to programming, consider\ninstead reading How to Design Programs. If you want an especially quick introduction to\nRacket, start with Quick: An Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of the Racket toolbox, but leaving precise details to The Racket\nReference and other reference manuals.\n1"
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > .../unsafe/alloc.rkt:35:6: loop
> > .../unsafe/alloc.rkt:27:0: deallocate
> > .../ffi/unsafe.rkt:2117:27: loop
> > .../private/more-scheme.rkt:265:2: call-with-exception-handler
> > call-in-empty-metacontinuation-frame
> > .../ffi/unsafe.rkt:2104:19: retry-loop
> > call-in-empty-metacontinuation-frame
> > call-with-empty-metacontinuation-frame-for-swap
> > cpointer-ref: contract violation
> > expected: cpointer?
> > given: "The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket or new to some part of\nRacket. It assumes programming experience, so if you are new to programming, consider\ninstead reading How to Design Programs. If you want an especially quick introduction to\nRacket, start with Quick: An Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of the Racket toolbox, but leaving precise details to The Racket\nReference and other reference manuals."
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: cpointer-ref: contract violation
> > expected: cpointer?
> > given: "The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket or new to some part of\nRacket. It assumes programming experience, so if you are new to programming, consider\ninstead reading How to Design Programs. If you want an especially quick introduction to\nRacket, start with Quick: An Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of the Racket toolbox, but leaving precise details to The Racket\nReference and other reference manuals."
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > .../unsafe/alloc.rkt:35:6: loop
> > .../unsafe/alloc.rkt:27:0: deallocate
> > .../ffi/unsafe.rkt:2117:27: loop
> > .../private/more-scheme.rkt:265:2: call-with-exception-handler
> > call-in-empty-metacontinuation-frame
> > .../ffi/unsafe.rkt:2104:19: retry-loop
> > call-in-empty-metacontinuation-frame
> > call-with-empty-metacontinuation-frame-for-swap
> > cpointer-ref: contract violation
> > expected: cpointer?
> > given: "pdfTeX-1.40.3"
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: cpointer-ref: contract violation
> > expected: cpointer?
> > given: "pdfTeX-1.40.3"
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > .../unsafe/alloc.rkt:35:6: loop
> > .../unsafe/alloc.rkt:27:0: deallocate
> > .../ffi/unsafe.rkt:2117:27: loop
> > .../private/more-scheme.rkt:265:2: call-with-exception-handler
> > call-in-empty-metacontinuation-frame
> > .../ffi/unsafe.rkt:2104:19: retry-loop
> > call-in-empty-metacontinuation-frame
> > call-with-empty-metacontinuation-frame-for-swap
> > cpointer-ref: contract violation
> > expected: cpointer?
> > given: "LaTeX with hyperref package"
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: cpointer-ref: contract violation
> > expected: cpointer?
> > given: "LaTeX with hyperref package"
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > .../unsafe/alloc.rkt:35:6: loop
> > .../unsafe/alloc.rkt:27:0: deallocate
> > .../ffi/unsafe.rkt:2117:27: loop
> > .../private/more-scheme.rkt:265:2: call-with-exception-handler
> > call-in-empty-metacontinuation-frame
> > .../ffi/unsafe.rkt:2104:19: retry-loop
> > call-in-empty-metacontinuation-frame
> > call-with-empty-metacontinuation-frame-for-swap
> > internal error: attempt to deschedule the current thread in atomic mode
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: internal error: attempt to deschedule the current thread in atomic mode
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > l
> > loop
> > dynamic-wind
> > temp52_0
> > .../ffi/unsafe.rkt:2117:27: loop
> > .../private/more-scheme.rkt:265:2: call-with-exception-handler
> > call-in-empty-metacontinuation-frame
> > .../ffi/unsafe.rkt:2104:19: retry-loop
> > call-in-empty-metacontinuation-frame
> > call-with-empty-metacontinuation-frame-for-swap
> > internal error: attempt to deschedule the current thread in atomic mode
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: internal error: attempt to deschedule the current thread in atomic mode
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > l
> > loop
> > dynamic-wind
> > temp52_0
> > .../ffi/unsafe.rkt:2117:27: loop
> > .../private/more-scheme.rkt:265:2: call-with-exception-handler
> > call-in-empty-metacontinuation-frame
> > .../ffi/unsafe.rkt:2104:19: retry-loop
> > call-in-empty-metacontinuation-frame
> > call-with-empty-metacontinuation-frame-for-swap
> > internal error: attempt to deschedule the current thread in atomic mode
> > exception raised by exception handler: abort-current-continuation: contract violation
> > expected: continuation-prompt-tag?
> > given: [?error-value->string-handler not ready?]; original exception raised: internal error: attempt to deschedule the current thread in atomic mode
> > context...:
> > proc
> > loop
> > call-in-empty-metacontinuation-frame
> > abort-current-continuation
> > loop
> > call-in-empty-metacontinuation-frame
> > l
> > loop
> > dynamic-wind
> >
> > … and on and on for another 95 megabytes.
> >
> > Any thoughts? What does raco test -p racket-poppler produce in your machine?
> >
> > John
> >
> >
> > > On Feb 20, 2020, at 3:11 PM, Jens Axel Søgaard <jens...@soegaard.net> wrote:
> > >
> > > Hi Again,
> > >
> > > It's working with stock 7.6. Note that DrRacket doesn't render the picts correctly in the repl, so you need
> > > to use
> > >
> > > (pict->bitmap (tex-math "x+1"))
> > >
> > > when using the repl. The reason is that DrRacket doesn't render the original pict; it makes a copy
> > > and renders the copy - but it can't copy picts that call out to the Cairo interface directly.
> > >
> > > Den tor. 20. feb. 2020 kl. 23.45 skrev John Clements <clem...@brinckerhoff.org>:
> > > Yes, I’m pretty much certain that the draw libraries were updated. Specifically, they had to be recompiled to comply with Apple’s notarization requirements.
> > >
> > > Is the requirement that the two cairo libraries have the same interface, or must they literally be binarily compatible?
> > >
> > > I don't know for sure - but I think the latter.
> > >
> > > The first time I got Poppler working I managed to build both all Racket libraries and Poppler
> > > and documented how I did. I believe that led Flatt to make some scripts in order to make it
> > > less painfull.
> > >
> > > Since then Flatt has kindly built Poppler each time the draw libraries were updated.
> > > Then I put them on https://github.com/soegaard/poppler-libs
> > >
> > > Also, is there any way to check the compatibility before dumping core?
> > >
> > > I don't know - but I do remember that I learned to check whether the dynamic
> > > linker used the proper libraries.
> > >
> > > See the last section of "Tips and tricks":
> > >
> > > https://github.com/soegaard/racket-osx-libs
> > >
> > > /Jens Axel
> > >
> > >
> >
> >
> >
> >
> >
> > --
> > --
> > Jens Axel Søgaard
> >
>
>
>
>
>
> --
> --
> Jens Axel Søgaard
>



Reply all
Reply to author
Forward
0 new messages