php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81578 Conditional jump or move depends on uninitialised value(s)
Submitted: 2021-10-31 15:55 UTC Modified: 2021-11-14 04:22 UTC
From: glash dot gnome at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Class/Object related
PHP Version: 8.0Git-2021-10-31 (snap) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: glash dot gnome at gmail dot com
New email:
PHP Version: OS:

 

 [2021-10-31 15:55 UTC] glash dot gnome at gmail dot com
Description:
------------
My custom zend_object look for doc_comment and get an error message from valgrind.

I can fix it with ecalloc insteadof emalloc,

// In Zend/zend_arena.h
static zend_always_inline zend_arena* zend_arena_create(size_t size)
{
    //zend_arena *arena = (zend_arena*)emalloc(size);
    zend_arena *arena = (zend_arena*)ecalloc(size, 1);

    [...]
}

but the initialization is partly already done in init_op_array ()
It's missing a :
op_array-> doc_comment = NULL;
but I don't know where.

Can someone take care of it? 

Test script:
---------------
static zend_object*
php_gobject_object_create_object(zend_class_entry *class_type)
{
    php_gobject_object *intern = zend_object_alloc(sizeof(php_gobject_object), class_type);

    zend_object_std_init(&intern->std, class_type);
    object_properties_init(&intern->std, class_type);
    // [...]
    zend_function *f;
    ZEND_HASH_FOREACH_PTR(&class_type->function_table, f) {
        if (f->op_array.doc_comment) {
            php_printf("\n", f->op_array.doc_comment->val);
        }
    }ZEND_HASH_FOREACH_END();

}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-02 15:04 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-11-02 15:04 UTC] cmb@php.net
> but the initialization is partly already done in init_op_array ()
> It's missing a :
> op_array-> doc_comment = NULL;

But that is initialized in init_op_array()[1].  Is it possible
that f->op_array is not initialized?

[1] <https://github.com/php/php-src/blob/php-8.0.12/Zend/zend_opcode.c#L65>
 [2021-11-02 15:22 UTC] nikic@php.net
Taking a stab in the dark, you're probably trying to treat an internal function as an op_array. internal functions don't have a doc comment. You need to check the function type for ZEND_USER_FUNCTION.
 [2021-11-14 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC