You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "jasmine-nahrain (via GitHub)" <gi...@apache.org> on 2024/01/25 02:52:47 UTC

[PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

jasmine-nahrain opened a new pull request, #11009:
URL: https://github.com/apache/trafficserver/pull/11009

   At the moment,  `unavailable_server_retry_responses` and `simple_server_retry_responses` will be nullptr's when parent_retry is enabled and the retry type does not match their type. e.g. parent_retry=SIMPLE_RETRY, `unavailable_server_retry_responses` will be null. But these values are both used in the code no matter what the type is. This has been causing a segmentation fault as the code is trying to use the .contain() method on what is currently a nullptr. This change ensures that they are always initialised with their default values when parent_retry is enabled, irrespective of the retry type.
   
   Should close #11005 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "maskit (via GitHub)" <gi...@apache.org>.
maskit commented on PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009#issuecomment-1915347939

   I may be wrong but this part looks problematic.
   https://github.com/apache/trafficserver/blob/f84038734069a2a2562329fecabd575cd4f59009/src/proxy/http/HttpTransact.cc#L420-L422
   If we hit line 795, which deletes `simple_server_retry_responses`, doesn't it cause a crash if we reach line 422?
   
   Creating an empty object with `new` just to avoid nullptr dereference sounds costly. I assume this particular code doesn't affect performance because it's called in `Init`, which suggests it's only run on startup. But that's still not a good practice, IMO. Deleting an object right after creating it looks silly too. I'd suggest having actual instances of `UnavailableServerResponseCodes` and `SimpleRetryResponseCodes` instead of pointers for them (in other words, `UnavailableServerResponseCodes` and `SimpleRetryResponseCodes` instead of `UnavailableServerResponseCodes *` and `SimpleRetryResponseCodes *`). This prevents nullptr dereferences and also memory leak.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "maskit (via GitHub)" <gi...@apache.org>.
maskit commented on PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009#issuecomment-1910678356

   Shouldn't we add nullptr checks instead because they still can be nullptr if we hit line 783 or 795?
   
   Unrelated to this change, but `simple_server_retry_responses` seem to be leaked (not deleted at the destructor, unlike `unavailable_server_retry_responses`).
   
   We may want to avoid the dynamic allocation in the first place.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "jasmine-nahrain (via GitHub)" <gi...@apache.org>.
jasmine-nahrain commented on PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009#issuecomment-1909324671

   [approve ci fedora]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on code in PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009#discussion_r1479059319


##########
tests/gold_tests/parent_proxy/parent-retry.test.py:
##########
@@ -0,0 +1,47 @@
+"""
+Test parent_retry config settings
+"""
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+Test.testName = "Test parent_retry settings"
+Test.ContinueOnFail = True
+
+
+class ParentRetryTest:
+    """
+    Test loading parent.config with parent_retry setting enabled
+    """
+    ts_parent_hostname = "localhost:8081"
+
+    def __init__(self):
+        """Initialize the test."""
+        self._configure_ts_child()
+
+    def _configure_ts_child(self):
+        self.ts_child = Test.MakeATSProcess("ts_child")
+        self.ts_child.Disk.parent_config.AddLine(
+            f'dest_domain=. method=get parent="{self.ts_parent_hostname}" parent_retry=unavailable_server_retry unavailable_server_retry_responses="502,503"'
+        )
+
+    def run(self):
+        tr = Test.AddTestRun()
+        tr.Processes.Default.StartBefore(self.ts_child)
+        tr.Processes.Default.Command = 'curl "{}" --verbose'.format(self.ts_child.Variables.port)

Review Comment:
   We use `f'...'` strings now (like you do above with parent_config) instead of `.format()` for all new tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "jasmine-nahrain (via GitHub)" <gi...@apache.org>.
jasmine-nahrain commented on PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009#issuecomment-1913745423

   > Shouldn't we add nullptr checks instead because they still can be nullptr if we hit line 783 or 795?
   By initialising both fields with their default values, it should not ever be a nullptr. I did it this way in case the values are called in other parts of the code. It means the initial value is never a nullptr.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "maskit (via GitHub)" <gi...@apache.org>.
maskit merged PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "zwoop (via GitHub)" <gi...@apache.org>.
zwoop commented on PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009#issuecomment-1947683938

   Cherry-picked to v9.2.x


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Segmentation crash caused by setting unavailable_server_retry_responses in parent.config [trafficserver]

Posted by "jasmine-nahrain (via GitHub)" <gi...@apache.org>.
jasmine-nahrain commented on PR #11009:
URL: https://github.com/apache/trafficserver/pull/11009#issuecomment-1922509312

   [approve ci autest]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org