lagrange: Lagrange crashes when it gets redirect response immediately after entering input
Hey! Lagrange keeps crashing from time to time after I do one very specific scenario. It happens not immediately but like after 5th or so attempt (I know, very specific… sorry). I discovered this issue while testing my framework and I wouldn’t be suprised if I am doing something wrong but I think crash is not expected anyway. I will paste server code snippet that maybe will help to understand scenario.
app.OnRequest("/input", (request, response) => {
if (request.Parameters == null)
{
response.SetInputHint("Please enter something: ");
response.Status = StatusCode.Input;
}
else
{
// redirect with parameters to /show route
response.SetRedirectURL(request.BaseURL + "/show?" + request.Parameters);
response.Status = StatusCode.RedirectTemp;
}
});
app.OnRequest("/show", (request, response) => {
if (request.Parameters == null)
{
// redirect back to /input
response.SetRedirectURL(request.BaseURL + "/input");
response.Status = StatusCode.RedirectTemp;
}
else
{
// show what you entered
response.RenderPlainTextLine("# " + request.Parameters);
}
});
Steps to reproduce:
- access route which responds with status code “10”, in this case “/input”
- enter anything
- server gets request with “/input?something” and immediately redirects to “/show?something” (I’ve tried relative and absolute URL - reproducible with both)
- repeat until Lagrange crashes - usually 4-8 attempts.
I’ve tried other browsers and I couldn’t reproduce the issue.
Please let me know if you need any additional info.
P.S. I love your browser!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 26 (14 by maintainers)
Commits related to this issue
- DocumentWidget: Crash after receiving a redirect The `GmRequest` object is destroyed after handling a redirect, but afterwards a check was still made to cache the request contents. IssueID #148 — committed to skyjake/lagrange by skyjake 3 years ago
- GmRequest: Use unique IDs to avoid confusion It is conceivable that a newly created GmRequest gets the same memory location than the one just destroyed. IssueID #148 — committed to skyjake/lagrange by skyjake 3 years ago
- DocumentWidget: Crash after receiving a redirect The `GmRequest` object is destroyed after handling a redirect, but afterwards a check was still made to cache the request contents. IssueID #148 — committed to skyjake/lagrange by skyjake 3 years ago
- GmRequest: Use unique IDs to avoid confusion It is conceivable that a newly created GmRequest gets the same memory location than the one just destroyed. IssueID #148 — committed to skyjake/lagrange by skyjake 3 years ago
I’ve pushed some multithreading fixes to the dev branch, they could be of help here.
The fix for #181 is included in v1.2.
Alright, I will take a look
I’ll try to figure out a way to reproduce this. I have seen a couple of crashes recently related to requests that finish very quickly, so there could be a race condition somewhere.