Bug 30 - Running reTurnServer --help crashes (pure virtual method called)
Summary: Running reTurnServer --help crashes (pure virtual method called)
Status: NEW
Alias: None
Product: resiprocate
Classification: Unclassified
Component: stack (libresip) (show other bugs)
Version: unspecified
Hardware: Intel All
: P1 blocker
Assignee: Owner of all unassigned bugs
Depends on:
Reported: 2012-07-16 18:03 CDT by Chris
Modified: 2012-07-17 11:17 CDT (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Chris 2012-07-16 18:03:08 CDT
I've seen this on both Linux and Mac with reSIProcate 1.8.4. I can run `reTurnServer` and have it choose the config file in my current working directory, but when I run `reTurnServer --help`, I immediately get a fault (it looks like the application is trying to call resip::ConfigParse::printHelpText, for whatever reason).
Comment 1 Chris 2012-07-17 11:17:09 CDT
Consider the following:

struct A
   A(void) { first(); }
   void first(void) { second(); }
   virtual void second(void) = 0;

struct B : public A
   virtual void second(void) { }

int main(void)
   B b;
   return 0;

This will crash with the "pure virtual method called" at runtime, because the compiler assumes A::first will be called when a concrete class has been constructed. However, A::A calls A::first before B has been initialized, so the runtime doesn't yet know about B::second, so it tries to call A::second.

This is exactly what is happening when `reTurnServer --help` is run. One solution is to refactor the code so that resip::ConfigParse has only the default constructor, and concrete subclasses of resip::ConfigParse call some init() method inside their constructors that parses the command line arguments.