GMLC-TDC / HELICS

Hierarchical Engine for Large-scale Infrastructure Co-Simulation (HELICS)
https://docs.helics.org/en/latest/
BSD 3-Clause "New" or "Revised" License
126 stars 40 forks source link

Seg fault when creating broker with invalid broker type when using the Python extension #67

Closed kdheepak closed 6 years ago

kdheepak commented 6 years ago
In [1]: import helics as h

In [2]: h.helicsCreateBroker("", "", "--help")
libc++abi.dylib: terminating with uncaught exception of type helics::HelicsException: unrecognized broker type
[1]    67607 abort      ipython
phlptp commented 6 years ago

What would be your preference for what to do in this case?

right now I am changing it to just return a nullptr, but the error handling in the C interface is somewhat an open question about messages and things like that.

phlptp commented 6 years ago

I think this is fixed now, but @kdheepak should check to be sure, in the C_Unit_test branch

kdheepak commented 6 years ago
$ ipython
Python 3.6.3 |Anaconda, Inc.| (default, Dec  5 2017, 17:30:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import helics

In [2]: import helics as h

In [3]: h.helicsCreateBroker("", "", "--help")
allowed options:

command line only:
  -? [ --help ]          produce help message
  --config-file arg      specify a configuration file to use

configuration:
  --interface arg        the local interface to use for the receive ports
  -b [ --broker ] arg    identifier for the broker
  --broker_address arg   location of the broker i.e network address
  --brokerport arg       port number for the broker priority port
  --localport arg        port number for the local receive port
  --port arg             port number for the broker's port
  --portstart arg        starting port for automatic port definitions

allowed options:

command line only:
  -? [ --help ]          produce help message
  --config-file arg      specify a configuration file to use

configuration:
  --root                 specify whether the broker is a root

allowed options:

command line only:
  -h [ --help ]          produce help message
  -v [ --version ]       helics version number
  --config-file arg      specify a configuration file to use

configuration:
  -n [ --name ] arg      name of the broker/core
  --federates arg        the minimum number of federates that will be
                         connecting
  --minfed arg           the minimum number of federates that will be
                         connecting
  --maxiter arg          maximum number of iterations
  --logfile arg          the file to log message to
  --loglevel arg         the level which to log the higher this is set to the
                         more gets logs (-1) for no logging
  --fileloglevel arg     the level at which messages get sent to the file
  --consoleloglevel arg  the level at which message get sent to the console
  --minbroker arg        the minimum number of core/brokers that need to be
                         connected (ignored in cores)
  --identifier arg       name of the core/broker
  --tick arg             number of milliseconds per tick counter if there is no
                         broker communication for 2 ticks then secondary
                         actions are taken
  --dumplog              capture a record of all messages and dump a complete
                         log to file or console on termination
  --timeout arg          milliseconds to wait for a broker connection

Out[3]: <Swig Object of type 'void *' at 0x10bd5a090>