Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1384: Refactor some common code in the Timer API for legibilit… #1428

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Castaglia
Copy link
Member

…y/tracing, and add trace logging of alarm blocking.

@Castaglia Castaglia self-assigned this Apr 24, 2022
@Castaglia Castaglia temporarily deployed to CI April 24, 2022 17:28 Inactive
@Castaglia Castaglia temporarily deployed to CI April 24, 2022 17:28 Inactive
@Castaglia Castaglia temporarily deployed to CI April 24, 2022 17:28 Inactive
@Castaglia Castaglia temporarily deployed to CI April 24, 2022 17:28 Inactive
@Castaglia Castaglia temporarily deployed to CI April 24, 2022 17:28 Inactive
@Castaglia Castaglia temporarily deployed to CI April 24, 2022 17:28 Inactive
time_t now;
if (alarms_blocked == TRUE) {
alarms_pending++;
return;
Copy link
Member Author

@Castaglia Castaglia Apr 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If alarms are blocked, we shouldn't enter the while loop at all. Previously, we'd enter the while loop, set nalarms = 0, and then check whether alarms were blocked. If they were, then perhaps the SIGALRM signal which triggered this function call might not be properly handled, and in fact may have been "forgotten" due to the nalarms = 0 setting. Perhaps that might be the cause of some of the symptoms/behaviors reported in this issue?

Note to self: It is possible to handle a SIGALRM signal while alarms are blocked; due to the ordering of signal handling in the ProFTPD code, pr_alarms_blocked() could be called after the SIGALRM signal is received, and before it is processed.

@@ -152,7 +152,7 @@ static void chk_on_blk_list(union block_hdr *blok, union block_hdr *free_blk,
#endif /* PR_USE_DEVEL */
}

/* Free a chain of blocks -- _must_ call with alarms blocked. */
/* Free a chain of blocks -- _must_ call with signals blocked. */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that attempting to use pr_trace_msg() in the pr_alarms_block() function leads to a stack overflow, since the trace logging code calls into the Pools API, which blocks alarms, which calls the trace logging code, etc.

To avoid this -- and to honor what the Pools API really needs here -- we block signals, rather than alarms. And this is more desirable, as pr_alarms_block() does not block SIGARLM signals, it only blocks the processing of the timer callbacks. In these Pool routines, we don't want interruptions at all via signals, thus pr_signals_block() is better here anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The follow-on, then, is that we cannot call pr_trace_msg() within the pr_signals_block() functions, either, lest we trigger the same stack overflow!

…y/tracing, and add trace logging of alarm blocking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant