padrino / padrino-framework

Padrino is a full-stack ruby framework built upon Sinatra.
http://www.padrinorb.com
MIT License
3.37k stars 509 forks source link

SystemStackError when using `partial` in the layout haml #2273

Open synek317 opened 1 year ago

synek317 commented 1 year ago

Do you want to request a feature or report a bug?

It might be a bug or my wrong configuration that I'm not aware of

What is the current behavior?

I have a very simple layout file 'application.haml':

!!! 5 %html %head %body = partial 'partials/foo' = yield

the partials/_foo.haml is an empty file. I get an infinite recursion error that eventually ends with SystemStackError.

I have tried all kind of weird things, like passing layout: false or :layout => false to the = partial line. I also tried to switch to = haml :'partials/_foo', layout: false and a lot of other things I don't remember now. None worked.

If the current behavior is a bug, please provide the steps to reproduce it and if possible a minimal demo of the problem via https://github.com/ or https://gist.github.com/

What is the expected behavior?

I would expect it to just work.

Which versions of Ruby, Padrino, Sinatra, Rack, OS are you using? Did this work in previous versions?

Ruby 2.7 (via official docker image, which uses Debian 11), Padrino 0.15.3, Sinatra 3.0.6, Rack 2.2.6.4

nesquena commented 1 year ago

Thanks for the report - @jkowens Any idea what might be happening here?

jkowens commented 1 year ago

Hey @nesquena, no I'm not sure why this would be creating an infinite loop. @synek317 can you push up a basic sample app that demonstrates this issue?

synek317 commented 1 year ago

@jkowens honestly speaking, it might be pretty hard. I've been experiencing this issue in a pretty huge, closed-source application. In another one, where the versions of mentioned crates were the same, all worked well.

I spend 2 days on investigations, then a friend of mine invented a workaround that didn't use this part of the application.

jkowens commented 1 year ago

@synek317 just to confirm, if you removed the partial from the application.haml layout file, the SystemStackError went away?

synek317 commented 1 year ago

@jkowens yes, exactly. I double- and triple-checked it, it was 100% reproducible, I'm also 100% sure there were no other changes. The partial file content was irrelevant, I experimented with an empty file.

Maybe it could be an issue with some specific versions of some nested dependencies? I worked with other Padrino applications too with the same Padrino and Sinatra versions and didn't experience similar issues.

Since I managed to workaround it and I cannot provide you a good example, feel free to just close this issue as impossible to reproduce.