I tried adding a fragment shader program to OSG::Geometry node as below.
    osg::ref_ptr<osg::Geometry> node = new osg::Geometry();
    osg::ref_ptr<osg::Program> m_program= new osg::Program;
    osg::ref_ptr<osg::Shader> fragShader = new osg::Shader(osg::Shader::FRAGMENT);
    //TODO Add LOG if shader failed to load
    if (!fragShader->loadShaderSourceFromFile("Shaders/Sel.frag"))
        return;
    m_program->addShader(fragShader);
    osg::StateSet* state = node->getOrCreateStateSet();
    state->setAttributeAndModes(m_program, osg::StateAttribute::ON);
At some point, I removed the program using the below method
state->removeAttribute(m_program);
After removing the attribute, the next immediate render frame loop frame() throws an exception as below.
I tried to debug the openscenegraph and found the map which is causing the issue.
Header file: State
Method name :
inline void State::applyAttributeList(AttributeMap& attributeMap,const StateSet::AttributeList& attributeList)
The variable which caused the exception.
attributeMap
if I am not removing the program state attribute, it is working fine. Only removing the attribute, causing the issue.

 
     
    