View Issue Details

IDProjectCategoryView StatusLast Update
0000094XdebugUncategorizedpublic2004-11-28 22:54
Reporterratchet Assigned To 
PrioritynormalSeveritymajorReproducibilityrandom
Status closedResolutionopen 
Summary0000094: xdebug_sprintf misbehaves with x86_64/glibc-2.3.3
Description

Specifically, using PHP CLI, xdebug_path_to_url produces either either a path of just "file://" or "file:///<garbage>" followed by a partial path.

Also, with PHP compiled with --enable-debug and xdebug.loaded with "zend_extension_debug=/path/to/xdebug.so" it simply segfaults in xdebug_sprintf after connecting to the listener.

Additional Information

According to Linux's vsnprintf man page, va_start and va_end should occur within the for(;;) loop used to calculate the result buffer's length. Patching xdebug_str.c as follows fixes the problem, and I am now able to step through PHP scripts with Komodo(!!!) using 64-bit PHP CLI and Xdebug.

Note, though, that this may not work with older versions of glibc or with other architecutres' or operating systems' versions of vsnprintf.

Index: xdebug_str.c

RCS file: /repository/xdebug/xdebug_str.c,v
retrieving revision 1.5
diff -u -r1.5 xdebug_str.c
--- xdebug_str.c 17 Dec 2003 20:50:27 -0000 1.5
+++ xdebug_str.c 6 Oct 2004 18:24:19 -0000
@@ -88,9 +88,10 @@

    new_str = (char *) xdmalloc(size);
  • va_start(args, fmt);
    for (;;) {
  • va_start(args, fmt);
    int n = vsnprintf(new_str, size, fmt, args);
  • va_end(args);
    if (n > -1 && n < size) {
    break;
    }
    @@ -101,7 +102,6 @@
    }
    new_str = (char *) xdrealloc(new_str, size);
    }
  • va_end(args);

    return new_str;

    }

TagsNo tags attached.
Operating System
PHP Version4.3.4

Activities

derick

2004-11-28 22:54

administrator   ~0000218

Fixed in CVS. Your patch was almost correct, and I committed a similar one. I do not believe that it can break on other systems and, for that matter, it works fine for me.

Issue History

Date Modified Username Field Change
2004-10-06 20:27 ratchet New Issue
2004-11-28 22:54 derick Status new => closed
2004-11-28 22:54 derick Note Added: 0000218
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized