Skip to content

GDB: Python Exception <class 'TypeError'>: exceptions must derive from BaseException #15923

Closed

Description

@DanielEScherzer

Description

The following code:

<?php

$a = 1;
var_dump( $a );

in /var/www/html/test.php. when run with GDB:

(gdb) set print pretty on
(gdb) break /usr/src/php/ext/standard/var.c:105
Breakpoint 1 at 0x4b6130: file /usr/src/php/ext/standard/var.c, line 105.
(gdb) run /var/www/html/test.php
Starting program: /usr/local/bin/php /var/www/html/test.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, php_var_dump (struc=0x7ffff54140f0, level=1) at /usr/src/php/ext/standard/var.c:113
113             if (level > 1) {
(gdb) p *struc

Where var.c:113 at the time was

if (level > 1) {

Resulted in this output:

$1 = Python Exception <class 'TypeError'>: exceptions must derive from BaseException
Python Exception <class 'TypeError'>: exceptions must derive from BaseException
{
  value = {
    lval = 1,
...
}

But I expected this output instead:

No errors

PHP Version

PHP 8.4-dev

Activity

  1. cmb69 commented on Sep 16, 2024

    @cmb69
    Member

    While I don't understand why PHP would throw a TypeError here, the error message is certainly not related to nice elephpants, but rather to nasty reptiles. ;)

  2. DanielEScherzer commented on Sep 16, 2024

    @DanielEScherzer
    MemberAuthor

    While I don't understand why PHP would throw a TypeError here, the error message is certainly not related to nice elephpants, but rather to nasty reptiles. ;)

    Its not a PHP type error, its a Python one - I boiled it down to a minimal reproduction case, but I was getting a lot of these (I just started using GDB for PHP)

    I see this is tagged as needing feedback - what more can I provide?

  3. cmb69 commented on Sep 16, 2024

    @cmb69
    Member

    The question is: why do you get a Python error when running/debugging PHP code? I think there is something wrong with your setup.

  4. DanielEScherzer commented on Sep 16, 2024

    @DanielEScherzer
    MemberAuthor

    The question is: why do you get a Python error when running/debugging PHP code? I think there is something wrong with your setup.

    I believe it is because the GDB stuff is written in python, see https://github.com/php/php-src/blob/1ce07b0957c9323e93c45d0a83c0133aa177a911/scripts/gdb/php_gdb.py

  5. ndossche commented on Sep 16, 2024

    @ndossche
    Member

    The error likely comes from this line:

    raise "Could not find zend_types.h: symbol zend_gc_refcount not found"

    You can't raise a string.
    @DanielEScherzer Are you using a release build? That could explain why it can't find the symbol required.

  6. DanielEScherzer commented on Sep 16, 2024

    @DanielEScherzer
    MemberAuthor

    The error likely comes from this line:

    raise "Could not find zend_types.h: symbol zend_gc_refcount not found"

    You can't raise a string.
    @DanielEScherzer Are you using a release build? That could explain why it can't find the symbol required.

    I didn't think I was, but running ./configure --enable-debug and then re-make-ing and trying again fixed the issue. I guess then the attempted error makes sense, but the actual error (from raising a string) is problematic and should still be fixed

  7. ndossche commented on Sep 16, 2024

    @ndossche
    Member

    Yeah, I'll fix it. Looks like it's just on the master branch.

  8. cmb69 commented on Sep 16, 2024

    @cmb69
    Member

    I believe it is because the GDB stuff is written in python, see https://github.com/php/php-src/blob/1ce07b0957c9323e93c45d0a83c0133aa177a911/scripts/gdb/php_gdb.py

    Ah, I hadn't noticed this yet.

  9. added a commit that references this issue on Sep 16, 2024
    99b763a
  10. added a commit that references this issue on Sep 17, 2024
    31e2ec6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions