********> bugfix 5.
Author: Wei Zhang
Date: 24 April 2008
Programs: sleap
Severity: Seems to be specific to Mac OSX
Description: Segfaults can occur when running sleap
Fix: Apply the following fix in amber10/src/gleap.
---------------------------------------------------------------------------
Index: leapsrc/Makefile
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/leapsrc/Makefile,v
retrieving revision 1.17
diff -p -r1.17 Makefile
*** leapsrc/Makefile 26 Mar 2008 16:44:26 -0000 1.17
--- leapsrc/Makefile 8 Apr 2008 19:32:19 -0000
*************** INCPATH = -I../mortsrc -I../mortsr
*** 21,30 ****
ifeq ($(OSTYPE),darwin)
LINK = g++ -static-libgcc
else
! LINK = g++ -static
endif
LFLAGS =
! LIBS = ../plugins/libplugins.a ../mortsrc/libmort.a ../freelib/readline/libreadline.a -lm
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake
--- 21,30 ----
ifeq ($(OSTYPE),darwin)
LINK = g++ -static-libgcc
else
! LINK = g++ -static-libgcc
endif
LFLAGS =
! LIBS = ../freelib/readline/libreadline.a -lm ../plugins/libplugins.a ../mortsrc/libmort.a
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake
*************** OBJECTS_DIR = ./
*** 49,60 ****
####### Files
! SOURCES = strbuff.cpp \
! strmain.cpp \
! plugins.cpp
! OBJECTS = strbuff.o \
! strmain.o \
! plugins.o
DESTDIR =
TARGET = sleap
--- 49,56 ----
####### Files
! SOURCES = strmain.cpp strbuff.cpp plugins.cpp
! OBJECTS = strmain.o strbuff.o plugins.o
DESTDIR =
TARGET = sleap
Index: leapsrc/plugins.cpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/leapsrc/plugins.cpp,v
retrieving revision 1.11
diff -p -r1.11 plugins.cpp
*** leapsrc/plugins.cpp 20 Mar 2008 22:08:41 -0000 1.11
--- leapsrc/plugins.cpp 8 Apr 2008 19:32:19 -0000
***************
*** 32,38 ****
--- 32,40 ----
#include
#include
#include
+ #include
+ amber::help_command g_help_command;
amber::add_command g_add_command2;
amber::addions_command g_addions_command2;
amber::addmap_command g_addpdbatommap_command2( "addpdbatommap" );
*************** amber::saveoff_command g_saveoff_command
*** 82,85 ****
amber::savemol2_command g_savemol2_command2;
amber::energy_command g_energy_command2;
amber::loadprep_command g_loadprep_command2;
-
--- 84,86 ----
Index: leapsrc/strmain.cpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/leapsrc/strmain.cpp,v
retrieving revision 1.14
diff -p -r1.14 strmain.cpp
*** leapsrc/strmain.cpp 18 Jan 2008 21:54:01 -0000 1.14
--- leapsrc/strmain.cpp 8 Apr 2008 19:32:19 -0000
*************** int main( int argc, char** argv )
*** 59,69 ****
- // for windows platform, you need to use at least one symbol defined in shared library,
- // to make it be loaded to memory
-
- #include "../plugins/help.hpp"
-
- amber::help_command g_help_command;
-
-
--- 59,61 ----
Index: mortsrc/guilib/command.cpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/mortsrc/guilib/command.cpp,v
retrieving revision 1.2
diff -p -r1.2 command.cpp
*** mortsrc/guilib/command.cpp 18 Dec 2006 14:48:47 -0000 1.2
--- mortsrc/guilib/command.cpp 8 Apr 2008 19:32:19 -0000
***************
*** 3,19 ****
namespace mort
{
command_i::command_i()
{
}
command_i::command_i( const string& name )
{
! control_t::insert( name, this );
}
command_i::~command_i()
{
}
} // namespace amber
--- 3,43 ----
namespace mort
{
+ using std::map;
+
command_i::command_i()
{
}
command_i::command_i( const string& name )
{
! insert( name, this );
}
command_i::~command_i()
{
+ }
+
+ map& command_i::dict()
+ {
+ static map g_commands;
+ return g_commands;
+ }
+
+ void command_i::insert( const string& name, command_i* inst )
+ {
+ dict()[name] = inst;
+ }
+
+ command_i* command_i::find( const string& name )
+ {
+ map::iterator i = dict().find( name );
+ if( i==dict().end() )
+ {
+ throw logic_error( name + ": command not found!" );
+ }
+
+ return i->second;
}
} // namespace amber
Index: mortsrc/guilib/command.hpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/mortsrc/guilib/command.hpp,v
retrieving revision 1.3
diff -p -r1.3 command.hpp
*** mortsrc/guilib/command.hpp 28 Mar 2007 15:32:09 -0000 1.3
--- mortsrc/guilib/command.hpp 8 Apr 2008 19:32:19 -0000
*************** namespace mort
*** 30,35 ****
--- 30,43 ----
/// making a new command object with given argument.
virtual shared_ptr clone( const vector& args ) const = 0;
+
+ static void insert( const string& name, command_i* inst );
+
+ static command_i* find( const string& name );
+
+ private:
+
+ static std::map& dict();
};
typedef vector argvec_t;
Index: mortsrc/guilib/control.cpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/mortsrc/guilib/control.cpp,v
retrieving revision 1.16
diff -p -r1.16 control.cpp
*** mortsrc/guilib/control.cpp 5 Feb 2008 21:42:16 -0000 1.16
--- mortsrc/guilib/control.cpp 8 Apr 2008 19:32:19 -0000
*************** namespace mort
*** 131,136 ****
--- 131,137 ----
bool control_t::run( const string& command )
{
+
assert( ! command.empty() );
vector args;
*************** namespace mort
*** 163,176 ****
string name = args[0];
! map::iterator i = g_commands.find( name );
! if( i == g_commands.end() )
! {
! throw logic_error( name + ": command not found!" );
! }
! command_ptr comm = i->second->clone(args);
comm->exec();
--- 164,174 ----
string name = args[0];
! command_i* pcmd = command_i::find( name );
! assert( pcmd != NULL );
! command_ptr comm = pcmd->clone(args);
comm->exec();
Index: mortsrc/pdbent/build.cpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/mortsrc/pdbent/build.cpp,v
retrieving revision 1.28
diff -p -r1.28 build.cpp
*** mortsrc/pdbent/build.cpp 12 Dec 2007 15:19:41 -0000 1.28
--- mortsrc/pdbent/build.cpp 8 Apr 2008 19:32:19 -0000
*************** namespace mort
*** 374,380 ****
}
else
{
- //std::cout << "building: " << type << std::endl;
pdbent::build_bymdl( *ri, *mdl, nmap, dst, idmap );
}
--- 374,379 ----
Index: plugins/add.cpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/plugins/add.cpp,v
retrieving revision 1.4
diff -p -r1.4 add.cpp
*** plugins/add.cpp 9 May 2007 19:46:06 -0000 1.4
--- plugins/add.cpp 8 Apr 2008 19:32:19 -0000
*************** namespace amber
*** 42,48 ****
throw logic_error( "Error: only an atom list is allowed to be added into a unit" );
}
! insert( *unit, *list );
return true;
}
--- 42,48 ----
throw logic_error( "Error: only an atom list is allowed to be added into a unit" );
}
! mort::insert( *unit, *list );
return true;
}
*************** namespace amber
*** 106,115 ****
}
amber::add_command g_add_command;
-
- amber::null_command g_addpdbatommap_command( "addpdbatommap" );
-
- amber::null_command g_addpdbresmap_command( "addpdbresmap" );
amber::null_command g_addatomtypes_command( "addatomtypes" );
--- 106,111 ----
Index: plugins/loadpdb.cpp
===================================================================
RCS file: /raid5/case/cvsroot/amber10/src/gleap/plugins/loadpdb.cpp,v
retrieving revision 1.15
diff -p -r1.15 loadpdb.cpp
*** plugins/loadpdb.cpp 11 Dec 2007 15:46:12 -0000 1.15
--- plugins/loadpdb.cpp 8 Apr 2008 19:32:19 -0000
*************** namespace amber
*** 55,60 ****
--- 55,62 ----
if( m_action=="loadpdb" )
{
+ // pff is pointer to force field, it is needed here because for
+ // inhibitor, we run parmchk to get force field parameters
molecule_ptr pff = content().get_mol( "_amber-atom" );
build_bymdl( *pmol, content(), *nmap, pff.get() );
}
---------------------------------------------------------------------------
Workarounds: none