Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60057 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39537 invoked from network); 17 Apr 2012 06:12:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2012 06:12:44 -0000 Authentication-Results: pb1.pair.com header.from=yader.hernandez@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yader.hernandez@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: yader.hernandez@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:46555] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/D0-34429-BD90D8F4 for ; Tue, 17 Apr 2012 02:12:44 -0400 Received: by obbup16 with SMTP id up16so1147928obb.29 for ; Mon, 16 Apr 2012 23:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=ifNCapyPhoNWNxxGnF9A+OQXpJPw9BGgcH3YmmHkkf0=; b=bamgOrygiMew4eXyhGhHn/y8pb8DdgIodzS4EstDDP4JCSrMQafJKiAiWUsZr+BF0c U+0hDoJHzoQ9nxqrtH9w4ebfyfSY8sTfdvKZXaii2ngGvUjGEgV2lHlWxmZUi27dfNfC YZGJFJ+I6jMXJdmSito8XOuiwOdpyyH5O8D/J4D+RtOPGB3e1IRaopbuBQb3OrfrcXbt jHrafSeg8sSuZU5gzD9Okp9KZCdUf7r6oJm4BZMGQtrxa2Qsx7ONg5aMnLXD0MpcXb7Q EROfa4ywnS5QlLuzFNr4hvY6H8HnXUqAfdZpM39+LQfZU6tj6ylfshhImrnJ3KMrfzBV IhkQ== MIME-Version: 1.0 Received: by 10.182.7.4 with SMTP id f4mr19807112oba.57.1334643161449; Mon, 16 Apr 2012 23:12:41 -0700 (PDT) Received: by 10.60.147.199 with HTTP; Mon, 16 Apr 2012 23:12:41 -0700 (PDT) Date: Mon, 16 Apr 2012 23:12:41 -0700 Message-ID: To: PHP Developers Mailing List Content-Type: multipart/alternative; boundary=f46d044518a18a462504bdd9d332 Subject: EXC_BAD_ACCESS, Could not access memory zval array type From: yader.hernandez@gmail.com (Yader Hernandez) --f46d044518a18a462504bdd9d332 Content-Type: text/plain; charset=ISO-8859-1 Hello, I'm trying to create an ArrayList as an extension. I'm currently implementing ArrayList::contains(mixed $element) but I'm running into a blocking issue. It's currently causing a segfault when you call contains. I've tried to track down what I'm doing wrong, but I've had no luck with it. When running gdb this is what I get: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x00000000000000000x00000001005812ca in _zend_is_inconsistent /* {{{ proto public boolean ArrayList::contain(mixed $element[, boolean strict]) Returns true if this list contains the specified element. */ ZEND_METHOD(arraymap_class, contains) { zval *element; zend_bool strict = 0; /* strict comparison or not */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &element, &strict) == FAILURE) { RETURN_FALSE; } zval *this = getThis(); arraylist_object *intern; intern = (arraylist_object *) zend_object_store_get_object(this TSRMLS_CC); /* Don't use "ht" as a variable, it's already being used. All ZEND_METHOD have "ht" defined. */ HashTable *hash_table = Z_ARRVAL_P(intern->elements); HashPosition pos; zval **current; zval res; /* comparison result */ int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function; if (strict) { is_equal_func = is_identical_function; } zend_hash_internal_pointer_reset_ex(hash_table, &pos); while (zend_hash_get_current_data_ex(hash_table, (void **)¤t, &pos) == SUCCESS) { is_equal_func(&res, element, *current TSRMLS_CC); if (Z_LVAL(res)) { RETURN_TRUE; } zend_hash_move_forward_ex(hash_table, &pos); } RETURN_FALSE; } I can't seem to spot any errors with this implementation. The next thing I thought that could be wrong is how I'm creating elements pointer, but that seems correct too: static zend_object_value create_arraylist_object(zend_class_entry *ce TSRMLS_DC) /* {{{ */ { zend_object_value retval; arraylist_object *intern; intern = emalloc(sizeof(arraylist_object)); intern->size = 0; zend_object_std_init(&intern->std, ce TSRMLS_CC); ALLOC_INIT_ZVAL(intern->elements); array_init(intern->elements); intern->std.ce = ce; object_properties_init(&intern->std, ce); retval.handle = zend_objects_store_put(intern, NULL, destroy_arraylist_object, NULL TSRMLS_CC); retval.handlers = &arraylist_object_handlers; return retval; } /* }}} */ I'm not getting any compilation errors or any type of warnings. Everything seems to be glueing itself correctly. I'm hoping someone can see what I'm doing wrong so that I can move forward with this. thanks! --f46d044518a18a462504bdd9d332--