Skip to content
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

PHP Fatal error: Allowed memory size #6395

Open
atasingorneq opened this issue Jan 6, 2019 · 21 comments
Open

PHP Fatal error: Allowed memory size #6395

atasingorneq opened this issue Jan 6, 2019 · 21 comments

Comments

@atasingorneq
Copy link

Expected behavior

No error

Actual behavior

Since one month on every worker call this error appears:
PHP Fatal error: Allowed memory size of 188743680 bytes exhausted (tried to allocate 67112960 bytes) in /src/Util/JsonLD.php on line 109

Friendica version you encountered the problem

2019.01-rc - 1292

Friendica source (git, zip)

git

PHP version

7.2.13
memory_limit = 350M
The error also appears, if i rise the memory_limit up to 500M

SQL version

5.5.5-10.0.34-MariaDB

@MrPetovan
Copy link
Collaborator

Thanks for the report, it is a known occurrence but without the context (full trace) it is impossible to fix as JsonLD is used in all ActivityPub communication, and it doesn't fail consistently.

@atasingorneq
Copy link
Author

What information you need? Shall i look for some special keywords in my logfile?

@MrPetovan
Copy link
Collaborator

Do you have any relevant log lines below the one you pasted in this issue? It could help determining what kind of ActivityPub call makes JsonLD loop.

@atasingorneq
Copy link
Author

No, there are no more log lines. This is an announcement from the cron log.
Today I set the php log level to report all and the friendica log to Debug. Than i remove the worker from the crontab and start the worker manuell, but i did not find any information in the logs. If you have an idea for a relevant keyword in the logfiles, you suggestion are welcome ;-)

@MrPetovan
Copy link
Collaborator

I was expecting a full stack trace with the Fatal Error message, but maybe it is only available with XDebug installed, which we don't recommend for production use. Thanks for the elaboration though.

@mark4409
Copy link

I can confirm that I'm also getting very regular entries like this, but unfortunately no stack trace. Also on PHP 7.2

@rabuzarus
Copy link
Collaborator

rabuzarus commented Feb 5, 2019

This is far away from being a full stack trace but I can say that at my node worker stops while discovering poco because of Allowed memory size of 134217728 bytes exhausted (tried to allocate 98570240 bytes) in /httpdocs/friendica/src/Util/JsonLD.php on line 115 error. I have now over 6000 entries in the workerqueue and it do not become less.
Below I added a snippet of my friendica logfile - I've added the $jsonobj which causes the error at https://github.com/friendica/friendica/blob/develop/src/Util/JsonLD.php#L114

019-02-05T20:05:31Z@log:30735:5c59ec7b88f5d631	[Info]:Worker.php:330:execFunction	Process 30735 - Prio 40 - ID 6478088: DiscoverPoCo ["DiscoverPoCo","update_server_directory",7795] - Process PID: wrk:30735:5c59ec8b980db889
2019-02-05T20:05:31Z@wrk:30735:5c59ec8b980db889	[Info]:DiscoverPoCo.php:61:execute	start 
2019-02-05T20:05:38Z@wrk:30735:5c59ec8b980db889	[Info]:JsonLD.php:114:compact	The jsonobj which resulting in Allowed memory exhausted error: stdClass Object
(
    [url] => https://shigusegubu.club/users/lizzeboof
    [type] => Person
    [tag] => Array
        (
        )

    [summary] => It&#39;s <span class='h-card'><a data-user='50843' class='u-url mention' href='https://shigusegubu.club/users/lizzeboof'>@<span>lizzeboof</span></a></span>, but from another world
    [publicKey] => stdClass Object
        (
            [publicKeyPem] => -----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwds+QNOimyTFB7Sxz6Sz
thv1Rp7Yf9gwVohoBZOgxbFJ6jd742xzeV/V+VMPCs940ubYrHUK6jPqQL7qW4Ah
gDsf06Prjcx9j9dDPcVRZBcDUPX1j0JlMqej7fn3w8EvNachtERWVxKn4lglglS3
z6Y/tw1tOO3tEpL+2UrxBLj4TL3GMQKrwSYeqaGFMPAmwrosCr2DekS2re29LYar
PZw1QKZUhQ5af2ZMC1RScIGqqrCaIU3sLnv7HXrpoQAl+FUehKLgF+6pZ03u+9Md
umS1HI7cKCnIXBpHPfobDyUC3O41irfwrFYdW5ANExTQKZiWLW2vKgvaee3tPOZX
cQIDAQAB
-----END PUBLIC KEY-----


            [owner] => https://shigusegubu.club/users/lizzeboof
            [id] => https://shigusegubu.club/users/lizzeboof#main-key
        )

    [preferredUsername] => lizzeboof
    [outbox] => https://shigusegubu.club/users/lizzeboof/outbox
    [name] => Otherworld Lizzu
    [manuallyApprovesFollowers] => 
    [inbox] => https://shigusegubu.club/users/lizzeboof/inbox
    [image] => stdClass Object
        (
            [url] => https://shigusegubu.club/media/1364962c-da78-4e65-9ec6-e096869027c7/060f7561ae2bab902dcbadbd9406c5c02630e48df864af4a66859e5395a583af.png
            [type] => Image
        )

    [id] => https://shigusegubu.club/users/lizzeboof
    [icon] => stdClass Object
        (
            [url] => https://shigusegubu.club/media/9b3b6249-40a4-401a-9d6f-bc2bb290ea86/a519301b8059d0dc0e12d921dd2df36df57ee302644d6199084bb94a66fa3b84.png
            [type] => Image
        )

    [following] => https://shigusegubu.club/users/lizzeboof/following
    [followers] => https://shigusegubu.club/users/lizzeboof/followers
    [endpoints] => stdClass Object
        (
            [sharedInbox] => https://shigusegubu.club/inbox
        )

    [@context] => Array
        (
            [0] => https://www.w3.org/ns/activitystreams
            [1] => https://shigusegubu.club/schemas/litepub-0.1.jsonld
            [2] => https://w3id.org/security/v1
        )

)

Edit: Friendica stable 2019.01

@MrPetovan
Copy link
Collaborator

Ping @annando

@annando
Copy link
Collaborator

annando commented Feb 7, 2019

Hmm, there's something wrong with this profile.

@gitkald
Copy link

gitkald commented Feb 11, 2019

I deleted some contacts. After this, I get the same error. I tried to insert ini_set('memory_limit','512M'); in the php file, but no effect. Same error.

Using: Friendica 'The Tazmans Flax-lily' 2019.01 - 1293, Master branch.

@annando
Copy link
Collaborator

annando commented Feb 18, 2019

I have some test code. It would be great if someone could test it, before we think about a better solution.

Please edit the file vendor/friendica/json-ld/jsonld.php (and save the original one).

Go to line 5747 (This is the function _parse_json). There please add these lines:

                if (($error != JSON_ERROR_NONE) && empty($rval)) {
                        $error = JSON_ERROR_NONE;
                        $rval = new stdClass();
                }

Please add it before the line switch ($error).

If this does work, then we have to see how to make a final solution.

@atasingorneq
Copy link
Author

OK, i will test it.

@atasingorneq
Copy link
Author

I apply the patch, wait one hour and no errors appears. I think, it works.

@rabuzarus
Copy link
Collaborator

@annando
Unfortunately, your test code doesn't resolve the fatal error on my system :-/

@atasingorneq
Copy link
Author

The same behavior here. At first there were fewer errors, but now there are more than before.

@annando
Copy link
Collaborator

annando commented Feb 28, 2019

Could you post the exact message, so that we can check whether it is the same line or some other place?

@atasingorneq
Copy link
Author

It is the same error
PHP Fatal error: Allowed memory size of 188743680 bytes exhausted (tried to allocate 48238592 bytes) in /var/www/virtual/paddler/html/src/Util/JsonLD.php on line 118

@annando
Copy link
Collaborator

annando commented Feb 28, 2019

Okay.

@gitkald
Copy link

gitkald commented Mar 12, 2019

I have the same error on my system. After one week, I got this error. If the error comes up, I ran the crontab worker command manualy and this fix it for one week.

Normaly I thought, that command line and cron are the same. But I saw, that the cronjob runs with a sh and my commandline with a bash shell. Could this be a solution?

Now I think I must wait for next sunday an we will see, if the cronjob with shell=/bin/bash, runs again.

@annando
Copy link
Collaborator

annando commented Mar 12, 2019

Which version are you using? The RC should now be fine.

@gitkald
Copy link

gitkald commented Mar 12, 2019

Master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants