Segmentation fault when using -screen none

Submitted by mschramm on Tue, 09/04/2018 - 21:14

Hello,
While I was running a test using python, I wanted no screen output.
I was told to use -screen none (liggghts -screen none -log none -in in.liggghts).
When doing so I received a segmentation fault error.
(I confirmed issue using the chute_wear example --> liggghts -screen none -in in.chute)

To get around this, I used -screen /dev/null

NOTE: -log none works as intended...

LIGGGHTS version
LIGGGHTS-PUBLIC 3.8.0

OS
Redhat 7

Please let me know if any other information is needed.

Thank you.

Daniel Queteschiner | Wed, 09/05/2018 - 09:49

The option -screen none sets the commonly used FILE pointer for screen output (screen) to NULL. However, fprintf which is used for printing the output requires a valid FILE pointer and thus any call to fprintf using screen must be guarded.
The fix for this bug is straight forward (I had to apply this to our fork of LIGGGHTS some time ago). Just search the source files for fprintf(screen and make sure that all of these calls are guarded by if(screen).
Most notably fix_mesh.cpp and input_mesh_tri.cpp have this error but it may be present in other files as well.