Menu

#41 printing open bracket { (ASCII123) freezes gui

open
nobody
puredata (322)
5
2007-12-03
2005-11-17
Anonymous
No

On WinXP and Miller's pd039_test7 typing '{' (ascii
123) after print in an object box hangs the gui,
apparently because the tcl is waiting for a closing '}'
before proceeding.

In the source code, dopost() in s_print.c, it looks
like four characters are escaped: '\', '{', '}', and ';'.
But if they are escaped they should not freeze the gui...

static void dopost(const char *s)
{
...
if (c == '\\' || c == '{' || c == '}' || c
== ';') <- if it's a dangerous character for tcl
upbuf[ptout++] = '\\'; <- add a
backslash before the dangerous character
upbuf[ptout] = s[ptin]; <- then put the
character
...
sys_vgui("pdtk_post {%s}\n", upbuf); <- then
send it to tcl interpreter

If I try entering them in a print box I get different
results. '\' and '}' are rejected:
\}: dropped
\\: dropped
';' is accepted
'{' freezes the gui.

In g_editor.c:

void canvas_key(t_canvas *x, t_symbol *s, int ac,
t_atom *av)
{

...
if (keynum == '\\' || keynum == '{' || keynum ==
'}') <-a dangerous character
{
post("%c: dropped", (int)keynum); <-should be
dropped, but for '{' this doesn't get printed
return;
}
...dopost() is called from post() so '{' is causing
trouble even when it is escaped with a backslash.

Submitted by Martin Peach
martinrp@vax2.condordia.ca

Discussion

  • Anonymous

    Anonymous - 2005-12-03

    Logged In: YES
    user_id=801174

    fixed in DesireData today.

     
  • Thomas Grill

    Thomas Grill - 2005-12-07

    Logged In: YES
    user_id=350252

    first, Matju 's fixes for the dopost function in s_print.c

    static void dopost(const char *s)
    {
    if (sys_printhook)
    (*sys_printhook)(s);
    else if (sys_printtostderr)
    fprintf(stderr, "%s", s);
    else
    {
    char upbuf[MAXPDSTRING];
    int i,j=0;
    for(i=0; s[i] && j<MAXPDSTRING-16; i++)
    {
    if (strchr("\\\"[]$\n",s[i])) upbuf[j++]='\\';
    if (s[i]=='\n') upbuf[j++]='n';
    else upbuf[j++] = s[i];
    }
    upbuf[j] = 0;
    sys_vgui("pdtk_post \"%s\"\n",upbuf);
    }
    }

     
  • Thomas Grill

    Thomas Grill - 2005-12-07

    Logged In: YES
    user_id=350252

    second:

    it's pretty clear that the bug must be in the socket
    receiver code for pd.tk inside t_tkcmd.c. In pd_readsocket
    starting with line 168 it says:
    /* search for locations that terminate a complete TK
    command. These are carriage returns which are not inside
    any braces. Braces can be escaped with backslashes (but
    backslashes themselves can't.) */

    When a "{: dropped" post comes in, the code in pd_readsocket
    must get confused because a brace is opened but none closed.
    There's no command-delimiting newline character found in
    that case.

     
  • Claude Heiland-Allen

    Logged In: YES
    user_id=769033

    In pd-0.39-2, typing { in a new object box hangs pd-gui
    until you type a corresponding }, at which point the
    following is printed in the console:

    \{: dropped
    \{: dropped
    \}: dropped
    \}: dropped

    The text typed (exclusively) between { and } is entered into
    the object box when the } is typed, too.

     
  • Hans-Christoph Steiner

    • summary: print character 123 freezes gui --> printing open bracket { (ASCII123) freezes gui
     
  • Claude Heiland-Allen

    Logged In: YES
    user_id=769033
    Originator: NO

    This bug is still present in pd-0.40-3.

    I noticed it when pdlua tried to print a "syntax error" message containing Lua source code on a line containing '{'.

     
  • Jonathan Wilkes

    Jonathan Wilkes - 2013-02-06

    Is this bug still present in 0.43? If so it needs to be addressed.

     

Anonymous
Anonymous

Add attachments
Cancel