Skip to content

grdimage and pscoast crashes when plotting with stereographic projection #4344

Closed

Description

@anbj

When doing gmt grdimage @earth_relief_30m -JS0/90/20c -P this happens:

$ gmt grdimage @earth_relief_30m -JS0/90/20c -P
grdimage [ERROR]: South boundary cannot be -90.0 for north polar stereographic projection
grdimage [ERROR]: Internal Failure = error
ERROR: Caught signal number 11 (Segmentation fault) at
/lib/x86_64-linux-gnu/libc.so.6(+0x15c181)[0x7f946382e181]
[0x0]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x26e)[0x7f9466161eee]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f9465c04730]
/lib/x86_64-linux-gnu/libc.so.6(+0x15c181)[0x7f946382e181]
/lib/x86_64-linux-gnu/libc.so.6(+0x4f021)[0x7f9463721021]
/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x576)[0x7f9463721f66]
/lib/x86_64-linux-gnu/libc.so.6(vsnprintf+0x90)[0x7f946374a7a0]
/usr/local/lib/libgmt.so.6(gmtlib_report_func+0x125)[0x7f946627baf5]
/usr/local/lib/libgmt.so.6(gmt_err_func+0x45)[0x7f946621c9c5]
/usr/local/lib/libgmt.so.6(GMT_grdimage+0x1321)[0x7f94663cbee1]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x3ee)[0x7f946617f41e]
gmt(main+0x260)[0x55df6c79e420]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f94636f609b]
gmt(_start+0x2a)[0x55df6c79f49a]

Looks like it's related to the implied -R (=global, including the south pole?).

Likewise with pscoast:

$ gmt pscoast -JS0/90/20c -W -R-180/180/-90/90
pscoast [ERROR]: South boundary cannot be -90.0 for north polar stereographic projection
pscoast [ERROR]: Internal Failure = error
ERROR: Caught signal number 11 (Segmentation fault) at
/lib/x86_64-linux-gnu/libc.so.6(+0x15c181)[0x7f0e4318a181]
[0x0]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x26e)[0x7f0e45abdeee]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f0e45560730]
/lib/x86_64-linux-gnu/libc.so.6(+0x15c181)[0x7f0e4318a181]
/lib/x86_64-linux-gnu/libc.so.6(+0x4f021)[0x7f0e4307d021]
/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x576)[0x7f0e4307df66]
/lib/x86_64-linux-gnu/libc.so.6(vsnprintf+0x90)[0x7f0e430a67a0]
/usr/local/lib/libgmt.so.6(gmtlib_report_func+0x125)[0x7f0e45bd7af5]
/usr/local/lib/libgmt.so.6(gmt_err_func+0x45)[0x7f0e45b789c5]
/usr/local/lib/libgmt.so.6(GMT_pscoast+0x4f49)[0x7f0e45dad9a9]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x3ee)[0x7f0e45adb41e]
gmt(main+0x260)[0x557fab775420]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f0e4305209b]
gmt(_start+0x2a)[0x557fab77649a]

The problem is the same if you want to draw a map of the south:

$ gmt pscoast -JS0/-90/10c -R-0/360/-90/90 -W
pscoast [ERROR]: North boundary cannot be +90.0 for south polar stereographic projection
pscoast [ERROR]: Internal Failure = error
ERROR: Caught signal number 11 (Segmentation fault) at
/lib/x86_64-linux-gnu/libc.so.6(+0x15c181)[0x7f9cfba8b181]
[0x0]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x26e)[0x7f9cfe3beeee]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f9cfde61730]
/lib/x86_64-linux-gnu/libc.so.6(+0x15c181)[0x7f9cfba8b181]
/lib/x86_64-linux-gnu/libc.so.6(+0x4f021)[0x7f9cfb97e021]
/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x576)[0x7f9cfb97ef66]
/lib/x86_64-linux-gnu/libc.so.6(vsnprintf+0x90)[0x7f9cfb9a77a0]
/usr/local/lib/libgmt.so.6(gmtlib_report_func+0x125)[0x7f9cfe4d8af5]
/usr/local/lib/libgmt.so.6(gmt_err_func+0x45)[0x7f9cfe4799c5]
/usr/local/lib/libgmt.so.6(GMT_pscoast+0x4f49)[0x7f9cfe6ae9a9]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x3ee)[0x7f9cfe3dc41e]
gmt(main+0x260)[0x56474a71e420]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f9cfb95309b]
gmt(_start+0x2a)[0x56474a71f49a]

May happen to other modules as well. I have only tested with pscoast and grdimage.

Activity

  1. PaulWessel commented on Oct 17, 2020

    @PaulWessel
    Contributor

    So hard-core GMT developers (Walter) would say if you don't understand that you cannot give -Rg|d with a polar projection then you deserve those errors. Kinder, gentler developers might offer different answers, such as

    • Do some sanity checking on -R -J and report if there is a domain problem (like above)
    • Recommend a more suitable -R, e.g. -R-180/180/0/90 or -R0/360/-90/0 for polar cases

    I hesitate to have GMT automatically "fix" these regions since we just don't know the users mind, but I am open to adding a new function

    gmtinit_sanity_check_RJ ()

    that is called at end of GMT_Parse_Common (it would only act if both -R -J are known) and again at top of gmt_map_setup. It could at least check the azimuthal cases, possibly some conic cases, Mercator with lats == 90 and more.

  2. PaulWessel commented on Oct 17, 2020

    @PaulWessel
    Contributor

    The only real problem with what you reported is the SEGV failures and crash after telling us what the issue is. So in a sense we do already check for these but let things die horribly regardless...

  3. anbj commented on Oct 17, 2020

    @anbj
    ContributorAuthor

    Just to be clear: It's the segfault I want to make you aware of.

  4. anbj commented on Oct 18, 2020

    @anbj
    ContributorAuthor

    I think gmt should tell what the issue is (as it does now), and then quit gracefully. Do not get into complicated sanity checking. As you say, you have no idea what the user is trying to do. Let the user know that this does not work, and then quit.

    The users incompetence (me) should not cause complex and obscure code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions