[Fdo-trac] [fdo-trac] #965: Static object destructors not called on Linux
FDO
trac_fdo at osgeo.org
Wed Jan 23 06:18:54 PST 2019
#965: Static object destructors not called on Linux
-----------------------+----------------------
Reporter: jng | Owner: jng
Type: defect | Status: assigned
Priority: major | Milestone:
Component: FDO API | Version:
Severity: 3 | Keywords:
External ID: |
-----------------------+----------------------
I've noticed in running the various unit tests that static object
destructors in various providers are not being called which results in the
various teardown functions that are supposed to be called when the
provider is being {{{dlclose()}}}'d are not being called.
Upon further reading, a better solution is to have a Linux-specific
teardown function decorated with {{{__attribute__((destructor))}}} like
so:
{{{
//Various providers use this pattern for global data
class InitClass
{
public:
InitClass()
{
//...provider-specific setup
}
~InitClass()
{
//...provider-specific teardown
}
}
static InitClass init; //Supposedly calls destructor when cleaned up, but
doesn't on Linux when dlclose()'d
#ifndef _WIN32
void __attribute__((destructor)) Teardown()
{
//...Call same provider-specific teardown as ~InitClass()
}
#endif
}}}
Such functions will be called when the provider is {{{dlclose()}}}'d
--
Ticket URL: <https://trac.osgeo.org/fdo/ticket/965>
FDO <http://fdo.osgeo.org/>
Feature Data Objects
More information about the fdo-trac
mailing list