New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'std::out_of_range' thrown when a neuron with multiple connection types loses all connections of one type #832

Closed
sanjayankur31 opened this Issue Sep 28, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@sanjayankur31
Contributor

sanjayankur31 commented Sep 28, 2017

Description of problem

If a neuron (probably any node) has multiple types of connections (synapses), say static_synapse and vogels_sprekeler_synapse, deleting all connections of one type results in nest throwing an std::out_of_range error.

Version-Release or Git commit:

Current head: f6959c3

How reproducible: (Always/Sometimes/Unsure)

Always. Reproducer script:

#!/usr/bin/env python3


import nest

stim = nest.Create(
    'poisson_generator', 1,
    {'rate': 300., 'origin': 0., 'start': 0., }
)
aneuron = nest.Create('parrot_neuron', 1)
neuronset1 = nest.Create('iaf_cond_exp', 10)
neuronset2 = nest.Create('iaf_cond_exp', 10)
neuronset3 = nest.Create('iaf_cond_exp', 10)

nest.CopyModel('vogels_sprekeler_synapse', 'stdp_1')
nest.CopyModel('static_synapse', 'static_2')
nest.CopyModel('static_synapse', 'static_3')


nest.Connect(stim, aneuron)
for n in neuronset1:
    nest.Connect(aneuron, [n],
                 syn_spec={'model': 'stdp_1', 'weight': -5., 'Wmax': -10.},
                 conn_spec={'rule': 'one_to_one'})

for n in neuronset2:
    nest.Connect(aneuron, [n],
                 syn_spec={'model': 'static_2', 'weight': 1.},
                 conn_spec={'rule': 'one_to_one'})

for n in neuronset3:
    nest.Connect(aneuron, [n],
                 syn_spec={'model': 'static_3', 'weight': 1.},
                 conn_spec={'rule': 'one_to_one'})

nest.Simulate(5000.)

print("Connections for aneuron: {}".format(
    nest.GetConnections(source=aneuron)))

for n in neuronset1:
    nest.Disconnect(pre=[aneuron[0]],
                    post=[n],
                    syn_spec={'model': 'stdp_1'},
                    conn_spec={'rule': 'one_to_one'}
                    )

print("After deletion connections for aneuron: {}".format(
    nest.GetConnections(source=aneuron)))

nest.Simulate(5000.)

(Also attached.)

Actual results

Simulation crashes with std::out_of_range exception like this:

terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 2) >= this->size() (which is 2)
[ankur:17984] *** Process received signal ***
[ankur:17984] Signal: Aborted (6)
[ankur:17984] Signal code:  (-6)
[ankur:17984] [ 0] /lib64/libpthread.so.0(+0x123b0)[0x7f1b268993b0]
[ankur:17984] [ 1] /lib64/libc.so.6(gsignal+0xcb)[0x7f1b25dcf69b]
[ankur:17984] [ 2] /lib64/libc.so.6(abort+0x1b0)[0x7f1b25dd14a0]
[ankur:17984] [ 3] /lib64/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x135)[0x7f1b150d0025]
[ankur:17984] [ 4] /lib64/libstdc++.so.6(+0x8fc16)[0x7f1b150cdc16]
[ankur:17984] [ 5] /lib64/libstdc++.so.6(+0x8eb19)[0x7f1b150ccb19]
[ankur:17984] [ 6] /lib64/libstdc++.so.6(__gxx_personality_v0+0x328)[0x7f1b150cd508]
[ankur:17984] [ 7] /lib64/libgcc_s.so.1(+0xfee3)[0x7f1b1c5ddee3]
[ankur:17984] [ 8] /lib64/libgcc_s.so.1(_Unwind_Resume+0x11e)[0x7f1b1c5de70e]
[ankur:17984] [ 9] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(_ZN4nest20EventDeliveryManager14deliver_eventsEi+0x80c)[0x7f1b16bccfd2]
[ankur:17984] [10] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(+0x1cfad7)[0x7f1b16badad7]
[ankur:17984] [11] /lib64/libgomp.so.1(GOMP_parallel+0x3f)[0x7f1b14e1ccdf]
[ankur:17984] [12] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(_ZN4nest17SimulationManager7update_Ev+0xe4)[0x7f1b16bac8ce]
[ankur:17984] [13] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(_ZN4nest17SimulationManager12call_update_Ev+0x32b)[0x7f1b16bac385]
[ankur:17984] [14] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(_ZN4nest17SimulationManager3runERKNS_4TimeE+0x255)[0x7f1b16babeab]
[ankur:17984] [15] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(_ZN4nest17SimulationManager8simulateERKNS_4TimeE+0x2f)[0x7f1b16bab46b]
[ankur:17984] [16] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(_ZN4nest8simulateERKd+0x223)[0x7f1b16b9372f]
[ankur:17984] [17] /opt/nest/lib64/python3.6/site-packages/nest/../../../libnestkernel.so(_ZNK4nest10NestModule16SimulateFunction7executeEP14SLIInterpreter+0x50)[0x7f1b16b601ca]
[ankur:17984] [18] /opt/nest/lib64/python3.6/site-packages/nest/../../../libsli.so(_ZN13FunctionDatum7executeEP14SLIInterpreter+0x17b)[0x7f1b15d661db]
[ankur:17984] [19] /opt/nest/lib64/python3.6/site-packages/nest/../../../libsli.so(_ZN14SLIInterpreter8execute_Em+0x1a6)[0x7f1b15d63eb4]
[ankur:17984] [20] /opt/nest/lib64/python3.6/site-packages/nest/../../../libsli.so(_ZN14SLIInterpreter7executeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xfa)[0x7f1b15d6356a]
[ankur:17984] [21] /opt/nest/lib64/python3.6/site-packages/nest/pynestkernel.so(+0x2d49c)[0x7f1b1859e49c]
[ankur:17984] [22] /opt/nest/lib64/python3.6/site-packages/nest/pynestkernel.so(+0x2d0bc)[0x7f1b1859e0bc]
[ankur:17984] [23] /lib64/libpython3.6m.so.1.0(_PyCFunction_FastCallDict+0x105)[0x7f1b26c276b5]
[ankur:17984] [24] /lib64/libpython3.6m.so.1.0(+0x18877a)[0x7f1b26c2e77a]
[ankur:17984] [25] /lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x35a)[0x7f1b26c5bd6a]
[ankur:17984] [26] /lib64/libpython3.6m.so.1.0(+0x14cb7a)[0x7f1b26bf2b7a]
[ankur:17984] [27] /lib64/libpython3.6m.so.1.0(+0x18883e)[0x7f1b26c2e83e]
[ankur:17984] [28] /lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x35a)[0x7f1b26c5bd6a]
[ankur:17984] [29] /lib64/libpython3.6m.so.1.0(PyEval_EvalCodeEx+0x2f7)[0x7f1b26c37a07]
[ankur:17984] *** End of error message ***
Aborted (core dumped)

Expected results

Simulation should run as expected.

Additional info

Unfortunately the stack-trace is incomplete (I don't know why). I ran the simulation in gdb and after stepping through it, found that the exception is thrown here at the at(i) statement:

  void
  send( Event& e, thread t, const std::vector< ConnectorModel* >& cm )
  {
    // for all primary connections delegate send to homogeneous connectors
    for ( size_t i = 0; i < primary_end_; i++ )
    {
      at( i )->send( e, t, cm );
    }
  }

There seems to be a condition where primary_end_ > size(), causing i = size() which should not occur as i should always be < size(). I'm not too well versed with the implementation of the connection data structures, but I've noticed that while primary_end_ is increased when new connections are added, it is never decreased - I think it should be when all connections of a particular type are removed.

@sanjayankur31

This comment has been minimized.

Show comment
Hide comment
@sanjayankur31
Contributor

sanjayankur31 commented Sep 28, 2017

sanjayankur31 added a commit to sanjayankur31/nest-simulator that referenced this issue Oct 1, 2017

Reduce primary_end_ marker for het connections
When all connections of a particular synapse type are removed, the
entry is removed from HetConnector and the primary_end_ marker should
also be reduced by one.

Fixes nest#832

sanjayankur31 added a commit to sanjayankur31/nest-simulator that referenced this issue Oct 2, 2017

Reduce primary_end_ marker for het connections
When all connections of a particular synapse type are removed, the
entry is removed from HetConnector and the primary_end_ marker should
also be reduced by one.

Fixes nest#832
@heplesser

This comment has been minimized.

Show comment
Hide comment
@heplesser

heplesser Oct 3, 2017

Contributor

@janhahne Since the primary_end_ is related to the split into primary and secondary connections, the latter related to gap/rate junctions, I think you may be qualified to help here. Clearly, deleting synapses causes some trouble here, see @sanjayankur31's analysis above. Interestingly, in his reproducer he does not seem to use gap junctions and still run into trouble.

Contributor

heplesser commented Oct 3, 2017

@janhahne Since the primary_end_ is related to the split into primary and secondary connections, the latter related to gap/rate junctions, I think you may be qualified to help here. Clearly, deleting synapses causes some trouble here, see @sanjayankur31's analysis above. Interestingly, in his reproducer he does not seem to use gap junctions and still run into trouble.

@janhahne

This comment has been minimized.

Show comment
Hide comment
@janhahne

janhahne Oct 4, 2017

Contributor

@sanjayankur31 Thank you for the detailed analysis of the issue! I agree with your conclusions and think that you already found the appropriate fix for the problem.

@heplesser The fix should probably be included in NEST 2.14.0 as it is even worse if gap junctions are present: In this case you don't run into an assertion, but you get wrong results for the gap-junctions part of the simulation! I will review the already existing PR #834 and add a unittest.

Contributor

janhahne commented Oct 4, 2017

@sanjayankur31 Thank you for the detailed analysis of the issue! I agree with your conclusions and think that you already found the appropriate fix for the problem.

@heplesser The fix should probably be included in NEST 2.14.0 as it is even worse if gap junctions are present: In this case you don't run into an assertion, but you get wrong results for the gap-junctions part of the simulation! I will review the already existing PR #834 and add a unittest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment