cogutil icon indicating copy to clipboard operation
cogutil copied to clipboard

Crash in logger during shutdown.

Open linas opened this issue 4 years ago • 1 comments

When the CogServer is shut down, there is a shared-library dtor race condition, where the cogutil logger threads are still running, even though the shared library is now gone. This looks like a crash, but the crash occurs only after the cogserver has exited (and after all unit tests have passed.) This makes test passes look like failures.

This only happens once out of every ten runs.

I first spotted this many years ago, and have repeatedly spent a lot of time trying to fix it, by adding more locks, a few sleep()s here and there, and any other trick I could think of, including not calling delete and making class dtors into no-ops. Despite great effort, I've been unable to find a fix. It seems appropriate to report this as a formal bug.

This is most easily demonstrated with the unit tests in https://github.com/opencog/atomspace-cog/ which "always" consistently pass... and then commonly crash during the shared library unload when the cogserver is stopped. This is ugly and undesired. (Out of 24 unit tests, it is likely that at least one will crash due to this bug.)

linas avatar Mar 01 '21 17:03 linas

One thing I have not tried, yet -- using

__attribute__((destructor (PRIORITY)))

for the shared-lib dtors. The higher-priority dtors will run earlier.

linas avatar Mar 07 '21 19:03 linas