make dlerror state and message thread-local and dynamically-allocated