Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty subplot causes ghostscript to hang #936

Closed
adigitoleo opened this issue Jul 4, 2022 · 5 comments
Closed

Empty subplot causes ghostscript to hang #936

adigitoleo opened this issue Jul 4, 2022 · 5 comments

Comments

@adigitoleo
Copy link

adigitoleo commented Jul 4, 2022

Julia 1.7.3
GMT (system install) 6.3
GMT.jl 0.42.4 (also on master)

I have found that this doesn't affect Windows.

Repro:

using GMT
subplot(grid = (3, 3), dims = (10, 10))
gmtend()

also happens for:

using GMT
gmtbegin("test.pdf")
subplot(grid = (3, 3), dims = (10, 10))
gmtend()

After this ghostscript needs to be killed manually (kill -9).

Neither of these GMT scripts seem to cause this, they throw an error as expected:

#!/bin/sh
gmt begin test pdf
  gmt subplot begin 3x3 -Baf -BWSen -F10/10
gmt end
#!/bin/sh
gmt begin test pdf
  gmt subplot begin 3x3 -Baf -BWSen -F10/10
  gmt subplot end
gmt end

I'm not able to follow how the subplot context is handled, I guess it happens through one of the global variables. Anyway, just found this while playing around with subplot for some examples.

@adigitoleo adigitoleo changed the title Empty subplot causes julia to hang Empty subplot causes ghostscript to hang Jul 4, 2022
@adigitoleo
Copy link
Author

OK I see now that the context is managed through IamSubplot:

julia> gmtbegin("test.pdf")

julia> subplot(grid = (3, 3), dims = (10, 10))

julia> GMT.IamSubplot[1]
true

Maybe gmtend is not checking for this.

@adigitoleo
Copy link
Author

Hmm, there is a try/catch, not sure why it isn't stopping this:

https://github.com/GenericMappingTools/GMT.jl/blob/master/src/common_options.jl#L3554-L3556

@joa-quim
Copy link
Member

joa-quim commented Jul 4, 2022

Can reproduce on Windows too. But here's what I think is happening. In plain GMT to use subplot one has to do:

gmt begin
     subplot begin
     subplot end
gmt end

but in GMT.jl when using subplot it implicitly sets the gmtbegin() ... gmtend() steps. So a gmtend() should not be used (as in your example) because it ends the ps without having finished the subplot(...).
For some reason ghostscript doesn't like the produced ps falls in some infinite loop.

Will see how to catch this situation.

@joa-quim
Copy link
Member

joa-quim commented Jul 4, 2022

Should be fixed by #939

@adigitoleo
Copy link
Author

Yep, this is solved for me on master now, throws an subplot [ERROR]: No subplot information file! which is expected.

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

No branches or pull requests

2 participants