Over the years we have had this error and at times I thought it was due to function size but we had it on functions a fraction the size of yours.
It usually seemed to be due to the function doing something inefficient with e.g. an array or large record.
With reports we tended to create an update to write the selection to temp files and then create a report to just read the temp files.
I imagine you don't fancy rewriting your report....

Rory