Fixed violation of the strict aliasing rules in 5d0edd35c4ce.
In order to reduce number of operations over rb-tree and process them in batches simultaneously, all the timers changes are temporary stored in array. While processing of these changes, the same memory is also used for storing pointers to postpone timers adding. As the same block of memory has been referenced by two different types of pointers (nxt_timer_change_t * and nxt_timer_t **), some compilers may reorder operations with these pointers and produce broken code. See ticket #221 on GitHub for a particular case. Now the same "nxt_timer_change_t" structure is used in both cases. Also, reverted the -fno-strict-aliasing flag, which has been introduced in ef76227ec159 as a workaround for this issue.
This commit is contained in:
@@ -10,11 +10,7 @@
|
||||
%define unit_version %%UNIT_VERSION%%
|
||||
%define unit_release %%UNIT_RELEASE%%%{?dist}.ngx
|
||||
|
||||
%if (0%{?rhel} == 6) && (%{_arch} == x86_64)
|
||||
%define CC_OPT %{optflags} -fno-strict-aliasing
|
||||
%else
|
||||
%define CC_OPT %{optflags}
|
||||
%endif
|
||||
|
||||
%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
|
||||
|
||||
|
||||
@@ -29,12 +29,7 @@ BuildRequires: openssl-devel
|
||||
BuildRequires: libopenssl-devel
|
||||
%endif
|
||||
|
||||
%if (0%{?rhel} == 6) && (%{_arch} == x86_64)
|
||||
%define CC_OPT %{optflags} -fno-strict-aliasing -fPIC
|
||||
%else
|
||||
%define CC_OPT %{optflags} -fPIC
|
||||
%endif
|
||||
|
||||
%define LD_OPT -Wl,-z,relro -Wl,-z,now -pie
|
||||
|
||||
%define CONFIGURE_ARGS $(echo "%%CONFIGURE_ARGS%%")
|
||||
|
||||
@@ -159,9 +159,9 @@ nxt_timer_change(nxt_event_engine_t *engine, nxt_timer_t *timer,
|
||||
static void
|
||||
nxt_timer_changes_commit(nxt_event_engine_t *engine)
|
||||
{
|
||||
nxt_timer_t *timer, **add, **add_end;
|
||||
nxt_timer_t *timer;
|
||||
nxt_timers_t *timers;
|
||||
nxt_timer_change_t *ch, *end;
|
||||
nxt_timer_change_t *ch, *end, *add, *add_end;
|
||||
|
||||
timers = &engine->timers;
|
||||
|
||||
@@ -170,7 +170,7 @@ nxt_timer_changes_commit(nxt_event_engine_t *engine)
|
||||
ch = timers->changes;
|
||||
end = ch + timers->nchanges;
|
||||
|
||||
add = (nxt_timer_t **) ch;
|
||||
add = ch;
|
||||
add_end = add;
|
||||
|
||||
while (ch < end) {
|
||||
@@ -185,7 +185,8 @@ nxt_timer_changes_commit(nxt_event_engine_t *engine)
|
||||
|
||||
timer->time = ch->time;
|
||||
|
||||
*add_end++ = timer;
|
||||
add_end->timer = timer;
|
||||
add_end++;
|
||||
|
||||
if (!nxt_timer_is_in_tree(timer)) {
|
||||
break;
|
||||
@@ -209,7 +210,7 @@ nxt_timer_changes_commit(nxt_event_engine_t *engine)
|
||||
}
|
||||
|
||||
while (add < add_end) {
|
||||
timer = *add;
|
||||
timer = add->timer;
|
||||
|
||||
nxt_debug(timer->task, "timer rbtree insert: %M±%d",
|
||||
timer->time, timer->bias);
|
||||
|
||||
Reference in New Issue
Block a user