forked from PowerDNS/pdns
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
logger: Use a function-level static var for the logger object
- Loading branch information
Showing
2 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
976adf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the crash that was observed on NetBSD/amd64, when a new thread would SEGV when it first tried to log something. It also fixes the crash, in the same situation, that was observed on NetBSD/arm32, even with the previous attempts that kept the /amd64 version from crashing.
However, now that the recursor is able to log without crashing on /arm32, it crashes with a SEGV later:
976adf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The auth server seems to work fine with this patch. With a gpgsql backend, I can create and modify zones, secure them, and query them as expected. Nothing fails, logging works.
976adf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test program on http://en.cppreference.com/w/cpp/language/storage_duration works just fine on the Pi, though, which should indicate that thread local storage basically works...?
976adf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure that the "Cannot access memory at address 0x85" means that thread local storage is corrupt. I think it's gdb that doesn't know what it's doing, and 0x85 might be an offset within the (thread local) data area representing the cache object. Viz:
Obviously, gdb simply doesn't handle thread local on arm, so it ought to have said the same above.
976adf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another interesting thing is that t_RC is declared as an uninitialized thread local pointer to a MemRecursorCache instance, and the first thing that's done with it is to check if it's false (by implication, null), in which case a new instance is created. Well, on NetBSD/arm32, compiled by GCC 6.4, it's not false right off the bat, so the 'new' doesn't happen. (Forcing that makes it run a bit further, but the program crashes with another segmentation violation shortly thereafter.) Whether the error is the non-zeroing of the variable, or the assumption that zeroing will happen, I do not know.
976adf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting back to where we started, though: this is clearly a good, simple fix for the original problem, which was crashes caused by attempting to log before the logger was properly initialized. :)