Skip to content

Adjust follow redirect logic to address a crash and avoid arguments shadowing - #4902

Merged
shinrich merged 1 commit into
apache:masterfrom
shinrich:cleanup-and-fix-crash-follow-redirect
Feb 1, 2019
Merged

shinrich merged 1 commit into
apache:masterfrom
shinrich:cleanup-and-fix-crash-follow-redirect

Conversation

@shinrich

Copy link
Copy Markdown
Member

Two changes. The change in HttpSM, is just renaming the parameters for HttpSM::redirect_request so they don't shadow HttpSM member variables.

The fix in HttpTransact::build_request addresses a crash we were seeing which I still do not fully understand. We have a cluster of machines configured as forward proxies that follow redirects. On this machine after I moved our build machine to use gcc-6.3, the builds would crash after around 5 minutes with the following stack.

[ 00 ] libc-2.17.so        __GI_raise                                                           
[ 01 ] libc-2.17.so        __GI_abort                                                           
[ 02 ] libc-2.17.so        __libc_message                                                       
[ 03 ] libc-2.17.so        _int_free                                                            
[ 04 ] traffic_server      destroy                                                              ( HdrHeap.h:463 )
[ 05 ] traffic_server      destroy                                                              ( HttpTransact.h:1145 )
[ 06 ] traffic_server      HttpSM::cleanup()                                                    ( HttpSM.cc:369 )
[ 07 ] traffic_server      HttpSM::destroy()                                                    ( HttpSM.cc:392 )
[ 08 ] traffic_server      HttpSM::kill_this()                                                  ( HttpSM.cc:7145 )
[ 09 ] traffic_server      HttpSM::main_handler(int, void*)                                     ( HttpSM.cc:2827 )
[ 10 ] traffic_server      Continuation::dispatchEvent(int, void*)                              ( Continuation.cc:46 )
[ 11 ] traffic_server      HttpTunnel::main_handler(int, void*)                                 ( HttpTunnel.cc:1657 )
[ 12 ] traffic_server      Http2Stream::main_event_handler(int, void*)                          ( Http2Stream.cc:93 )
[ 13 ] traffic_server      EThread::process_event(Event*, int)                                  ( UnixEThread.cc:136 )
[ 14 ] traffic_server      EThread::process_queue(Queue<Event, Event::Link_link>*, int*, int*)  ( UnixEThread.cc:175 )
[ 15 ] traffic_server      EThread::execute_regular()                                           ( UnixEThread.cc:235 )
[ 16 ] traffic_server      spawn_thread_internal                                                ( Thread.cc:85 )
[ 17 ] libpthread-2.17.so  start_thread                                                         

Building the code with compilers from devtoolset 7 or 8 would avoid the problem. Removing the redirect_info.redirect_url completely also solves the problem. And truthfully I don't see why we need to set the request_url again in build_request when we had just set it in redirect_request. I ran an instrumented build to make more checks to see when the client_request (base_request) URL differs from the redirect_info.redirect_urls, and in my runs it never differed, but perhaps there is an additional edge case that our deployment does not exercise?

This change also seems to make the crash go away.

Looking at the details of the stack, m_size is 0, so the system heap free() is called instead of the ATS thread_allocator free method. I don't know why the m_size is set to 0. I assume that the rediredt_url URL object is already corrupted before it gets to this destroy call.

But I have stared at this for a couple days already. This semantically equivalent (and shorter) sequence seems to address the issue.

I am also open to replacing redirect_info.redirect_url with a local variable in the HttpSM::redirect_request method if we decide that we don't need to double set the client request URL.

@shinrich shinrich added this to the 9.0.0 milestone Jan 31, 2019
@shinrich shinrich self-assigned this Jan 31, 2019
@shinrich

Copy link
Copy Markdown
Member Author

[approve ci autest]

@shinrich
shinrich merged commit 25e91b4 into apache:master Feb 1, 2019
@bryancall bryancall modified the milestones: 9.0.0, 8.1.0 Mar 27, 2019
@bryancall

Copy link
Copy Markdown
Contributor

Cherry picked to 8.1.0

@zwoop zwoop modified the milestones: 8.1.0, 8.1.0-nogo, 9.0.0 Mar 18, 2020
@zwoop

zwoop commented Mar 26, 2020

Copy link
Copy Markdown
Contributor

This doesn't cherry-pick cleanly to 8.1.x, do we need this for 8.1.0? If not, please remove Project 8.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants