protocolbuffers / protocolbuffers/protobuf
PHP Extension - Segmentation fault when serialize() is called on a protobuf message
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 72k
- Forks
- 16.3k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 140
Description
The PHP C extension segfaults when serialize() is called on a protobuf message.
[!IMPORTANT]
This is a unusual use case but the extension should not crash if a proto message is serialize by mistake.
What version of protobuf and what language are you using?
Version: main
Language: php
OS: Linux
What did you do?
<?php
# serialize_segfault.php
require_once (dirname(__DIR__) . '/vendor/autoload.php');
use Foo\TestMessage;
$msg = new TestMessage(['optional_string' => "Hello, World!"]);
serialize($msg);
# Compile the extension
./php/tests/compile_extension.sh
# Run script
php -d display_errors=on -dextension=../ext/google/protobuf/modules/protobuf.so serialize_segfault.php
What did you expect to see
# no errors.
What did you see instead?
Segmentation fault
Patch here
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash with serialize_segfault.php using php/tests/compile_extension.sh and the provided PHP extension command. Inspect the PHP C extension path exercised by serialize($msg), then compare the behavior with the referenced patch. Done means the script completes without a segmentation fault or other errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100