Skip to content
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

Thread-safe GLOBALs in NET_RECEIVE. #2908

Open
1uc opened this issue Jun 11, 2024 · 0 comments
Open

Thread-safe GLOBALs in NET_RECEIVE. #2908

1uc opened this issue Jun 11, 2024 · 0 comments

Comments

@1uc
Copy link
Collaborator

1uc commented Jun 11, 2024

The following MOD file:

NEURON {
    POINT_PROCESS ThreadVar
    GLOBAL gw
    THREADSAFE
}

ASSIGNED {
    gw
}

INITIAL {
    gw=0
}

NET_RECEIVE(weight (uS)) {
    gw = gw + weight
}

contains a "thread variable", i.e. global variable that's written to along with the promise that everything is THREAD_SAFE.

It generates the following code:

#define _gth         0
#define gw_ThreadVar _thread1data[0]
#define gw           _thread[_gth].get<double*>()[0]

...

static void _net_receive(Point_process* _pnt, double* _args, double _lflag) {
    Prop* _p;
    Datum* _ppvar;
    Datum* _thread;
    NrnThread* _nt;
    _nrn_mechanism_cache_instance _ml_real{_pnt->_prop};
    auto* const _ml = &_ml_real;
    size_t const _iml{};
    _thread = nullptr;
    _nt = (NrnThread*) _pnt->_vnt;
    _ppvar = _nrn_mechanism_access_dparam(_pnt->_prop);
    // ...
    { gw = gw + _args[0]; }
}

which should result in a nullptr dereference when accessing gw, because _thread == nullptr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant