Missing zend_return_unwrap_ref() calls trigger assertion failures:

Đang mở
#25,404 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, php
Lĩnh vực
backend, testing-qa

Hướng nghiên cứu

Start by reading the linked issue #20628 and tracing the listed reproductions through RecursiveIteratorIterator::callHasChildren(), callGetChildren(), RecursiveFilterIterator::hasChildren(), and zend_call_method() in zend_test. Find where returned references need unwrapping, then add regression coverage for the reproductions and verify the assertion failures are gone.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Extension: standard Extension: zend_test Status: Verified

The following cases trigger assertion failures, tested on latest 8.6 dev (0dbc4a7953a8aca38d0cf04fa4fb4ac076f00419)

php: Zend/zend_vm_execute.h:2167: const zend_op *ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER(zend_execute_data *, const zend_op *): Assertion `((call->func->common.fn_flags & (1 << 12)) && !zend_return_should_unwrap_ref(call)) ? (zval_get_type(&(*(ret))) == 10) : !(zval_get_type(&(*(ret))) == 10)' failed.
Aborted (core dumped)
`RecursiveIteratorIterator::callHasChildren()`
<?php

class Demo implements RecursiveIterator {

	public bool $v = true;

	public function getChildren(): ?RecursiveIterator { return null; }
	public function &hasChildren(): bool { return $this->v; }

	public function current(): mixed { return null; }
	public function key(): mixed { return null; }
	public function next(): void {}
	public function rewind(): void {}
	public function valid(): bool { return true; }

}

$r = new RecursiveIteratorIterator(new Demo());
var_dump($r->callHasChildren());
`RecursiveIteratorIterator::callGetChildren()`
<?php

class Demo implements RecursiveIterator {

	public mixed $v = null;

	public function &getChildren(): ?RecursiveIterator { return $this->v; }
	public function hasChildren(): bool { return true; }

	public function current(): mixed { return null; }
	public function key(): mixed { return null; }
	public function next(): void {}
	public function rewind(): void {}
	public function valid(): bool { return true; }

}

$r = new RecursiveIteratorIterator(new Demo());
var_dump($r->callGetChildren());
`RecursiveFilterIterator::hasChildren()`
<?php

class ConcreteRecursiveFilterIterator extends RecursiveFilterIterator {

	public function accept(): bool { return true; }

}

class Demo implements RecursiveIterator {

	public bool $v = true;

	public function getChildren(): ?RecursiveIterator { return null; }
	public function &hasChildren(): bool { return $this->v; }

	public function current(): mixed { return null; }
	public function key(): mixed { return null; }
	public function next(): void {}
	public function rewind(): void {}
	public function valid(): bool { return true; }

}

$r = new ConcreteRecursiveFilterIterator(new Demo());
var_dump($r->hasChildren());
`zend_call_method()` from zend_test
<?php

class Demo {
	public mixed $v = true;
	public function &returnsRef() { return $this->v; }
}

$d = new Demo();
var_dump(zend_call_method($d, 'returnsRef'));

Cross-link #20628

Ngôn ngữ chính
C
Star
41.8k
Fork
8.5k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
145

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của php/php-src

Tất cả issue của php/php-src

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.