{"action":"created","issue":{"url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/issues/1575","labels_url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/issues/1575/labels{/name}","comments_url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/issues/1575/comments","events_url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/issues/1575/events","html_url":"https://github.com/pedromorgan/flightgear-issues-test/issues/1575","id":60981097,"number":1575,"title":"double free/smart ptr pb in SimGear GroundLightManager","user":{"login":"pedromorgan","id":123932,"avatar_url":"https://avatars.githubusercontent.com/u/123932?v=3","gravatar_id":"","url":"https://api.github.com/users/pedromorgan","html_url":"https://github.com/pedromorgan","followers_url":"https://api.github.com/users/pedromorgan/followers","following_url":"https://api.github.com/users/pedromorgan/following{/other_user}","gists_url":"https://api.github.com/users/pedromorgan/gists{/gist_id}","starred_url":"https://api.github.com/users/pedromorgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedromorgan/subscriptions","organizations_url":"https://api.github.com/users/pedromorgan/orgs","repos_url":"https://api.github.com/users/pedromorgan/repos","events_url":"https://api.github.com/users/pedromorgan/events{/privacy}","received_events_url":"https://api.github.com/users/pedromorgan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/labels/imported","name":"imported","color":"FFFFFF"},{"url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/labels/OSG","name":"OSG","color":"009800"},{"url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/labels/SimGear","name":"SimGear","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-13T04:32:00Z","updated_at":"2015-03-13T04:32:18Z","closed_at":null,"body":"_From [fabr...@bellet.info](https://code.google.com/u/115928946400022671124/) on October 29, 2014 20:57:38_\n\nI noticed a systematic crash of FlightGear 3.2.0 on exit, on Fedora-21, caused by this error detected by valgrind :\r\n\r\n==21878== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.\r\n==21878== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info\r\n==21878== Command: fgfs --aircraft=ufo\r\n==21878== Parent PID: 21581\r\n==21878==\r\n==21878== Invalid read of size 8\r\n==21878==    at 0x8167537: UnknownInlinedFun (ScopedLock:54)\r\n==21878==    by 0x8167537: osg::StateAttribute::removeParent(osg::StateSet*) (StateAttribute.cpp:37)\r\n==21878==    by 0x817A993: osg::StateSet::clear() (StateSet.cpp:571)\r\n==21878==    by 0x817ABCD: osg::StateSet::~StateSet() (StateSet.cpp:176)\r\n==21878==    by 0x817AE68: osg::StateSet::~StateSet() (StateSet.cpp:177)\r\n==21878==    by 0x628657E: UnknownInlinedFun (Referenced:198)\r\n==21878==    by 0x628657E: ~ref_ptr (ref_ptr:35)\r\n==21878==    by 0x628657E: ~GroundLightManager (GroundLightManager.hxx:32)\r\n==21878==    by 0x628657E: simgear::GroundLightManager::~GroundLightManager() (GroundLightManager.hxx:32)\r\n==21878==    by 0xA9DC381: __run_exit_handlers (exit.c:82)\r\n==21878==    by 0xA9DC3D4: exit (exit.c:104)\r\n==21878==    by 0xA9C2FE6: (below main) (libc-start.c:323)\r\n==21878==  Address 0xfbe4410 is 0 bytes inside a block of size 24 free'd\r\n==21878==    at 0x4C2B103: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==21878==    by 0xA9DC6D9: __cxa_finalize (cxa_finalize.c:56)\r\n==21878==    by 0x80414D2: ??? (in /usr/lib64/libosg.so.3.2.1)\r\n==21878==    by 0x4010506: _dl_fini (dl-fini.c:252)\r\n==21878==    by 0xA9DC381: __run_exit_handlers (exit.c:82)\r\n==21878==    by 0xA9DC3D4: exit (exit.c:104)\r\n==21878==    by 0xA9C2FE6: (below main) (libc-start.c:323)\r\n==21878==\r\n\r\nI'm not an expert in C++, but I assume the osg-3.2.1 smart pointer infrastructure causes a problem when destroying the osg::StateSet* members of this class. (because it's a ReferencedSingleton object?). It worked fine with the osg version shipped in Fedora 20 (3.2.0). A possible fix that works for me:\r\n\r\n--- a/simgear/scene/tgdb/GroundLightManager.hxx\r\n+++ b/simgear/scene/tgdb/GroundLightManager.hxx\r\n@@ -32,16 +32,16 @@ namespace simgear\r\n class GroundLightManager : public ReferencedSingleton<GroundLightManager> {\r\n public:\r\n     GroundLightManager();\r\n-    osg::StateSet* getRunwayLightStateSet() { return runwayLightSS.get(); }\r\n-    osg::StateSet* getTaxiLightStateSet() { return taxiLightSS.get(); }\r\n-    osg::StateSet* getGroundLightStateSet() { return groundLightSS.get(); }\r\n+    osg::StateSet* getRunwayLightStateSet() { return runwayLightSS; }\r\n+    osg::StateSet* getTaxiLightStateSet() { return taxiLightSS; }\r\n+    osg::StateSet* getGroundLightStateSet() { return groundLightSS; }\r\n     // The SGUpdateVisitor manages various environmental properties,\r\n     // so use it.\r\n     void update (const SGUpdateVisitor* updateVisitor);\r\n     unsigned getLightNodeMask(const SGUpdateVisitor* updateVisitor);\r\n protected:\r\n-    osg::ref_ptr<osg::StateSet> runwayLightSS;\r\n-    osg::ref_ptr<osg::StateSet> taxiLightSS;\r\n-    osg::ref_ptr<osg::StateSet> groundLightSS;\r\n+    osg::StateSet *runwayLightSS;\r\n+    osg::StateSet *taxiLightSS;\r\n+    osg::StateSet *groundLightSS;\r\n };\r\n }\n\n_Original issue: http://code.google.com/p/flightgear-bugs/issues/detail?id=1576_"},"comment":{"url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/issues/comments/78794570","html_url":"https://github.com/pedromorgan/flightgear-issues-test/issues/1575#issuecomment-78794570","issue_url":"https://api.github.com/repos/pedromorgan/flightgear-issues-test/issues/1575","id":78794570,"user":{"login":"pedromorgan","id":123932,"avatar_url":"https://avatars.githubusercontent.com/u/123932?v=3","gravatar_id":"","url":"https://api.github.com/users/pedromorgan","html_url":"https://github.com/pedromorgan","followers_url":"https://api.github.com/users/pedromorgan/followers","following_url":"https://api.github.com/users/pedromorgan/following{/other_user}","gists_url":"https://api.github.com/users/pedromorgan/gists{/gist_id}","starred_url":"https://api.github.com/users/pedromorgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedromorgan/subscriptions","organizations_url":"https://api.github.com/users/pedromorgan/orgs","repos_url":"https://api.github.com/users/pedromorgan/repos","events_url":"https://api.github.com/users/pedromorgan/events{/privacy}","received_events_url":"https://api.github.com/users/pedromorgan/received_events","type":"User","site_admin":false},"created_at":"2015-03-13T04:32:17Z","updated_at":"2015-03-13T04:32:17Z","body":"_From [fabr...@bellet.info](https://code.google.com/u/115928946400022671124/) on January 07, 2015 02:55:20_\n\nobserved on a Fedora-21 x86_64, OSG, SimGear and FlightGear recompiled from source, SimGear (branch origin/release/3.2.0), FlightGear (branch origin/release/3.2.0), and OSG (svn branch OpenSceneGraph-3.2), gcc-4.9.2, glibc-2.20."}}