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

Serialization segmentation fault when serializing references #12522

Closed
ssigwart opened this issue Oct 25, 2023 · 2 comments
Closed

Serialization segmentation fault when serializing references #12522

ssigwart opened this issue Oct 25, 2023 · 2 comments

Comments

@ssigwart
Copy link

Description

The following code causes a segmentation fault.

<?php

class TestA
{
	public TestB $b;
	public function __serialize(): array
	{
		return [serialize($this->b)];
	}
	public function __unserialize(array $data): void
	{
		$this->b = unserialize($data[0]);
	}
}
class TestB
{
	public TestA $a;
}
$a = new TestA();
$b = new TestB();
$a->b = $b;
$b->a = $a;
echo serialize($a);

This probably isn't code people would actually use, but I was trying to debug a related unserializing bug and came across this.

PHP Version

PHP 8.0.30; PHP 8.2.11

Operating System

No response

@nielsdos
Copy link
Member

I can reproduce the segfault on 8.1-8.2.
You have infinite recursion, so I don't think this is actually a bug?
Noteworthy: on 8.3 this would cause an error exception instead: Uncaught Error: Maximum call stack size of 8306688 bytes reached. Infinite recursion?.

@ssigwart
Copy link
Author

Yeah, it's not code anyone should probably use. Like I said in the original issue, I was trying to simplify a different serialization bug I was seeing and stumbled across this, so I thought I'd report it. Since PHP 8.3 causes an exception instead, it probably makes sense to just close this.

Thanks for the quick response.

@nielsdos nielsdos closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
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

2 participants