vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.54k stars 660 forks source link

Memory issue running Psalm Github Action #11087

Open jrgdiaz opened 1 week ago

jrgdiaz commented 1 week ago

Hello !

I have a psalm set up in github actions that gave me the following memory error, hoping someone can provide information as to why it may be happening?

The codebase i'm targeting is 62M, it has given me this error twice in the same 18% mark. but the weird thing to me is that i have targeted a 238M codebase and it takes a while but it's able to execute that successfully

Run ./src/vendor/bin/psalm --taint-analysis --report=results.sarif --dump-taint-graph=taints.dot
Warning: "findUnusedBaselineEntry" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedCode" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedBaselineEntry" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedCode" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Target PHP version: [8](https://github.com/jrgdiaz/my-psalm-action/actions/runs/10661088953/job/29546071130#step:9:9).1 (inferred from current PHP version).
Scanning files...
Analyzing files...

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  60 / 316 (18%)
░░░░░░░░░░░░░░░░░░░░░░░PHP Fatal error:  Allowed memory size of 858[9](https://github.com/jrgdiaz/my-psalm-action/actions/runs/10661088953/job/29546071130#step:9:10)934592 bytes exhausted (tried to allocate 8388616 bytes) in /home/runnjrgdiaz/my-psalm-action/src/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Methods.php on line 1161
Fatal error: Allowed memory size of 8589934592 bytes exhausted (tried to allocate 8388616 bytes) in /home/runnjrgdiaz/my-psalm-action/src/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Methods.php on line [11](https://github.com/jrgdiaz/my-psalm-action/actions/runs/10661088953/job/29546071130#step:9:12)61
Error: Process completed with exit code 255.
psalm-github-bot[bot] commented 1 week ago

Hey @jrgdiaz, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.

ging-dev commented 1 week ago

may be php -d memory_limit=-1 ./src/vendor/bin/psalm will help

jrgdiaz commented 1 week ago

-d memory_limit=-1

Hi !

I tried, but got the same error.

Run php -d memory_limit=-1 ./src/vendor/bin/psalm --taint-analysis --report=results.sarif --dump-taint-graph=taints.dot
Warning: "findUnusedBaselineEntry" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedCode" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedBaselineEntry" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Warning: "findUnusedCode" will default to "true" in Psalm 6. You should explicitly enable or disable this setting.
Target PHP version: [8](https://github.com/jrgdiaz/my-psalm-action/actions/runs/10670902017/job/29575781361#step:9:9).1 (inferred from current PHP version).
Scanning files...
Analyzing files...
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  60 / 316 (18%)
░░░░░░░░░░░░░░░░░░░░░░░PHP Fatal error:  Allowed memory size of 858[9](https://github.com/jrgdiaz/my-psalm-action/actions/runs/10670902017/job/29575781361#step:9:10)934592 bytes exhausted (tried to allocate 8388616 bytes) in /home/runner/work/my-psalm-action/my-psalm-action/src/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Methods.php on line 1161
Fatal error: Allowed memory size of 8589934592 bytes exhausted (tried to allocate 8388616 bytes) in /home/runner/work/my-psalm-action/my-psalm-action/src/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Methods.php on line [11](https://github.com/jrgdiaz/my-psalm-action/actions/runs/10670902017/job/29575781361#step:9:12)61
Error: Process completed with exit code 255.
orklah commented 1 week ago

Does that codebase runs correctly without taint analysis?

jrgdiaz commented 1 week ago

Nope, same error even with --taint-analysis removed

I also tried different versions of target codebase.

Could it be something in the code i'm scanning interfering with psalm?

This is the code i'm targeting:

https://wordpress.org/plugins/events-manager/advanced/