Bug #769

Segfault in GMT_Call_Module

Added by Michael over 1 year ago. Updated over 1 year ago.

Status:ClosedStart date:2015-09-22
Priority:NormalDue date:
Assignee:Paul% Done:

0%

Category:-
Target version:Candidate for next bugfix release
Affected version:5.x-svn Platform:

Description

If GMT session created with mode=1 (use return instead of exit in case of error), and module arguments contain a redirection to file without write permissions, then the call GMT_Call_Module finished with segfault. Simple test program:

#include <gmt.h>

int main() {
void* gmtapi;
char* text="GMT";
char* args="-R130/160/40/60 -JM12c -Xa2c -Ya2c -B5/5/swNE →/proc/cmdline";
struct GMT_OPTION* opts;
int ret;

gmtapi=GMT_Create_Session(text,2,1,0);
opts=GMT_Create_Options(gmtapi,0,args);
ret=GMT_Call_Module(gmtapi,"psbasemap",GMT_MODULE_OPT,opts);
printf("%i\n",ret);
GMT_Destroy_Options(gmtapi,&opts);
GMT_Destroy_Session(gmtapi);
return 0;
}

Tested on gmt-5.1.2 and svn revision 14899.
Backtrace for r14899
#0 _IO_vfprintf_internal (s=0x0, format=0x7ffff5180486 "%d W\n", ap=0x7fffffffe1d8) at vfprintf.c:1271
#1 0x00007ffff517e05d in PSL_command (C=0x604da0, format=0x7ffff5180486 "%d W\n") at /tmp/save/gmt5-dev/src/pslib.c:4931
#2 0x00007ffff516ddbc in PSL_setlinewidth (PSL=0x604da0, linewidth=1.5) at /tmp/save/gmt5-dev/src/pslib.c:1371
#3 0x00007ffff792530b in GMT_setpen (GMT=0x7ffff7e88010, pen=0x7ffff7eb0778) at /tmp/save/gmt5-dev/src/gmt_plot.c:3224
#4 0x00007ffff791e154 in GMT_map_basemap (GMT=0x7ffff7e88010) at /tmp/save/gmt5-dev/src/gmt_plot.c:2370
#5 0x00007ffff7aac101 in GMT_psbasemap (V_API=0x603e80, mode=-1, args=0x60ac80) at /tmp/save/gmt5-dev/src/psbasemap.c:199
#6 0x00007ffff77c359a in GMT_Call_Module (V_API=0x603e80, module=0x400a98 "psbasemap", mode=-1, args=0x60ac80) at /tmp/save/gmt5-dev/src/gmt_api.c:5960
#7 0x00000000004008dd in main () at gmttest.cpp:13

History

#1 Updated by Paul over 1 year ago

  • Status changed from New to Resolved
  • Assignee set to Paul
  • Target version set to Candidate for next bugfix release

Thanks. Obviously we have never checked the return code seriously since in the command line modules we always wrote to stdout. Now, one can, as you did, give a file and it leads to an fopen. We did check for that failure but now the module will return without an¥ plotting and no SEGV. In r14902.

#2 Updated by Paul over 1 year ago

  • Status changed from Resolved to Closed

Closing issue.

Also available in: Atom PDF