Latest Tweets

plplot5.9.9 libraries on Ubuntu Xenial 16.04 segfault

The issue

According to some professors working in my department, newer versions of the plplot library ship with an entirely new API, rendering all that legacy scientific code unusable. So instead of re-writing all the code that make use of the plplot routines, they have asked me to install a previous version prior to all these changes. Plplot 5.9.9, that ships out-of-the-box with Debian Wheezy distros, is as good as any.

After compiling the original debian package on some modern GNU/Linux distros and testing that all was running fine, I did the same on an Ubuntu 16.04 (Xenial) box. However, this time I was not that lucky; running a scientific piece of code that made use of plplot 5.9.9 crashed:

./plp_preccyl < plp_input
-164.213572416971 173.427378522441
Aborted (core dumped)

Compiling the binary with Debugging Symbols

I added the debugging symbols to the plp_proccyl binary in order to trace the segmentation fault, and then I re-run the code inside a gdb session:

(gdb) run < plp_input
Starting program: /src/test/plp_preccyl < plp_input
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/”.
[New Thread 0x2aaac0a5f700 (LWP 3510)]
[New Thread 0x2aaac0c60700 (LWP 3511)]
[New Thread 0x2aaac0e61700 (LWP 3512)]
[New Thread 0x2aaac19ec700 (LWP 3513)]
[New Thread 0x2aaac1bed700 (LWP 3514)]
-164.213572416971 173.427378522441
[Thread 0x2aaac1bed700 (LWP 3514) exited]

Thread 1 “plp_preccyl” received signal SIGSEGV, Segmentation fault.
0x00002aaabbb2512d in gtk_container_add () from /usr/lib/x86_64-linux-gnu/

Once the segfault was triggered, I used the bt command to see the program’s back-trace:

(gdb) bt
#0 0x00002aaabbb2512d in gtk_container_add ()
at /plplot-5.9.9/drivers/qt.cpp:104
#11 0x00002aaab2342dfd in plD_init_rasterqt (pls=0x2aaaaaf2ddc0 <pls0>)
at /plplot-5.9.9/drivers/qt.cpp:278
#12 0x00002aaaaacea5b9 in plP_init () at /plplot-5.9.9/src/plcore.c:140
#13 0x00002aaaaacef004 in c_plinit () at /plplot-5.9.9/src/plcore.c:2248
#14 0x000000000040c4c2 in start_plot (device=…, kdev=168004192,
filename=<error reading variable: Cannot access memory at address 0x18>,
icolmap=<error reading variable: Cannot access memory at address 0x0>,
.tmp.DEVICE.len_V$d40=166761088, .tmp.FILENAME.len_V$d43=35) at plp_preccyl.f:2173
#15 0x0000000000414b3c in make_plot_z (pzvz=…, nrp=168004192,
ntp=<error reading variable: Cannot access memory at address 0x18>,

According to the back-trace, the segmentation fault was fired during the plotting routine using the qt driver. So I decided to try a quick-and-dirty fix; re-compile plplot without support for the qt driver.

Disabling the qt driver

To disable the support for the qt driver inside the plplot library, I set the directive DEFAULT_NO_QT_DEVICES to ON in  cmake/modules/drivers-init.cmake:

“Disable all qt devices by default (ON) or enable qt devices individually by default (OFF)”

Then I cleaned plplot5.9.9 build directory and re-built it from scratch:

debian/rules clean

debian/rules binary

Once the building process was finished, I re-installed it under the directory /usr/local/plplo599:

cd debian/build_tmp && make install

Finally, I re-compiled the plp_preccyl program and I re-run it. This time, the program finished its execution with no issues at all, plotting all the figures in different graphic formats (png, eps, pdf).

 The binaries

If you need this particular version of plplot and you are running an Ubuntu 16.04 64-bit (Xenial), you can get the binaries from here. Decompress them under /usr/local and make sure to change your Makefiles accordingly to make use of the new include and lib directories. Before running your program, don’t forget to set the LD_LIBRARY_PATH environment variable to match plplot5.9.9 lib directory!