-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Always send lowlevel_error response to client #2812
Conversation
I think we are going to need a regression test 😅 , any ideas? |
With this class BrokenApp
def initialize(app)
@app = app
end
def call(env)
[200, nil, []]
end
end
use BrokenApp
map '/' do
run lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello World"]] }
end and with Puma 5.6.1
with this branch $ cat Gemfile_PR
# frozen_string_literal: true
source "https://rubygems.org"
gem "puma", github: "https://github.com/puma/puma/pull/2812"
I'm thinking about this, looks like two responses?
|
Maybe we need a better example? Somewhere soon after where if headers.is_a? Hash
raise 'headers from app cannot be frozen' if headers.frozen?
else
raise "Improper headers (#{headers.class}) from app"
end |
Diff:
|
Barrier for merge here is a test that fails on #2731 but passes on this branch. |
I had a look at this, and made some changes. See the last commit in my fork's branch: https://github.com/MSP-Greg/puma/tree/pr2812-f1 A couple of style simplifications, and some begin/rescue/ensure rearranging, which, of course, makes the diff a mess. Anyway, the issue @dentarg mentioned above is fixed with the I have not run the names.pn specs mentioned elsewhere. HTH, Greg |
@MSP-Greg Thanks! Your changes pass the name.pn specs. Cherry picked your commit into this PR. |
Thanks for checking. I fixed the conflict. Re a test, if the issue is the one @dentarg mentioned above, showing the response start as:
the issue was fixed in the fixup patch. Previously, the regex in the test was:
That regex matches the response that dentarg's config.ru generated, but that is an invalid response. The fixup anchored the regex with Anyway, if that is the cause of the name.pn spec failures, then this is good to go. |
@MSP-Greg I'm not sure it is the cause. Your test change passes on v5.6.0. |
@nateberkopec You're right, sorry. I think this PR was clearing Do you recall what specs were failing? |
I haven't been able to get a test to fail locally, but |
These specs sometimes fail:
https://github.com/fishpercolator/name.pn/blob/main/features/signup_and_edit_profile.feature These specs make a handful of requests each, other than that I don't see anything special. Maybe @pedantic-git can give some more details on what those spec do? |
Hi @baelter - those are just following links with Capybara. Turbolinks is enabled on the app so there is some work involved in the process of "following a link" but there's nothing special about those particular lines. In my limited testing experience with this issue I found it was more likely to be related to the (number of? specific?) tests that had been run ahead of the ones that failed. Maybe puma reaches some kind of limit or race condition? |
I've got an idea about what's causing the problem, I hope to check it this weekend. As with most code, there are parts that might be considered 'brittle', and this has shown that we need more tests. There has been mention of 'cookies'/session data. I assume that lines up with the logs of the failed tests? |
Whenever I saw tests fail in my own runs, the symptom was always an "unauthenticated" version of the page coming back when the previous request had been authenticated. I couldn't work out what was going wrong beyond that. |
@pedantic-git do you use CurrentAttributes in your app to track authentication variables? I don't think it's cookies, I think it's something to do with threads. |
@joeldrapper Afaik there's no CurrentAttributes in there - it's just the standard cookie session store used with Devise/Warden. |
@joeldrapper It leaks on Rails 7 as well. I've deployed |
@rainerborene I'm sorry to hear that! The consequences of CurrentAttributes not being contained to the request execution are really serious. It's literally designed to be relied on for authentication attributes. My tests showed I don't know how, but this control flow change seems to cause the Rails app executor callbacks not to fire in some circumstances. It seems like a puma thread can get stuck in this state for a while. I haven't been able to reproduce the issue locally even using the same docker image that reproduced in staging. |
If we can figure out if we're actually causing an issue with CurrentAttributes, then we can do that, but I can't yank (which definitely breaks people's apps) for something that may or may not be broken. |
@nateberkopec I think 5.6.0 should be yanked. We know it is broken (somehow). Someone using 5.6.0 might not notice something is wrong and I think that is worse than having "bundle install" not work and having to fix that by upgrading to 5.6.1. |
The security issue here turned in to GHSA-rmj8-8hhh-gv5h |
We will not be yanking 5.6.0, as this issue existed in all versions of Puma and Rails. Users should upgrade Rails or Puma. |
@nateberkopec Since you found and fixed the underlying issue, do you still need more proof in this PR? |
Yes, we need more proof - we never committed a test for that fix 😅 |
Description
Add back f8acac1 and closes #2808
Problematic lines where f8acac1#diff-b58a5aaef75ecf535b6fc4546c848b0f576f9cf27e37b27c59015251097d5736R113-R114 and 117
The former lead to incorrect control flow in cases.
Your checklist for this pull request
[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.