Hi,
Lately, while working on a patch, i've had some strange crashes. I think i have found the source at splitfilename. When you are sending symbols to it, after a while it simply crashes. Attached is a patch which illustrates this behaviour - type some asdfasdf into the symbol atoms and prepare for segfault.
I'm on linux, and have tried this on three pd installs - 0.38(-4?) devel, Miller's 0.38-4 and the latest debian package.
regards, Johannes
#N canvas 0 0 450 300 10; #X obj 127 186 splitfilename; #X symbolatom 127 77 10 0 0 0 - - -; #X text 202 78 <- enter a few random strings here; #X symbolatom 142 127 10 0 0 0 - - -; #X text 221 124 <- or perhaps here; #X obj 142 148 makefilename /foo/baz/bar/%s; #X connect 1 0 0 0; #X connect 3 0 5 0; #X connect 5 0 0 0;
Johannes Burström wrote:
Hi,
Lately, while working on a patch, i've had some strange crashes. I think i have found the source at splitfilename. When you are sending symbols to it, after a while it simply crashes. Attached is a patch which illustrates this behaviour - type some asdfasdf into the symbol atoms and prepare for segfault.
I'm on linux, and have tried this on three pd installs - 0.38(-4?) devel, Miller's 0.38-4 and the latest debian package.
unfortunately i cannot really reproduce this. how many symbols do you consider "a few" ?
but you could run a debugger to see where it crashes: $ gdb pd % run -lib iemlib2 splitfilenametest.pd % bt
and post the output of "bt".
additionally it often helps to run pd with "-stderr" so any error-messages will not immediatly vanish with the tk-console when pd dies.
mfg.a.er IOhannes
Hi
IOhannes m zmoelnig wrote:
unfortunately i cannot really reproduce this. how many symbols do you consider "a few" ?
"a few" would be anything from 2-3 to 50 (sometimes even more - and very randomly). Thats "fdshiol<enter>fjsdkl<enter>...[repeat until crash]". And here are my outputs:
pd -stderr: free(): invalid pointer 0x8215550! pd_gui: pd process exited Segmenteringsfel
gdb:
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 1115)] 0x401ece03 in mallopt () from /lib/libc.so.6 (gdb) bt #0 0x401ece03 in mallopt () from /lib/libc.so.6 #1 0x401ec763 in calloc () from /lib/libc.so.6 #2 0x0809d935 in getbytes (nbytes=136562160) at m_memory.c:24 #3 0x0809da84 in binbuf_text (x=0x8213fd8, text=0xbfffd680 "pd ping ; key 1 13 0;;;_L 0 ; 1 ;", size=9) at m_binbuf.c:70 #4 0x080a8905 in socketreceiver_doread (x=0x8213ff8) at s_inter.c:402 #5 0x080a6ad8 in socketreceiver_read (x=0x8213ff8, fd=555) at s_inter.c:505 #6 0x080a86cf in sys_domicrosleep (microsec=136562160, pollem=1) at s_inter.c:170 #7 0x080a7db8 in sys_microsleep (microsec=136562160) at s_inter.c:184 #8 0x080a340f in m_scheduler () at m_sched.c:481 #9 0x080ad23b in main (argc=136562160, argv=0x823c5f0) at s_entry.c:27
Thanks, Johannes
but you could run a debugger to see where it crashes: $ gdb pd % run -lib iemlib2 splitfilenametest.pd % bt
and post the output of "bt".
additionally it often helps to run pd with "-stderr" so any
error-messages will not immediatly vanish with the tk-console when pd dies.
mfg.a.er IOhannes
PD-list@iem.at mailing list UNSUBSCRIBE and account-management ->
Johannes Burström wrote:
Hi
IOhannes m zmoelnig wrote:
unfortunately i cannot really reproduce this. how many symbols do you consider "a few" ?
your testpatch crashed immediately after i send my reply.... so it _does_ occur (but it is not easily "reproducible")
could you try to replace splitfilename.c with the attached file and recompile iemlib2 and look whether this fixes the crash ?
i have also checked my change into the CVS but don't know whether you have access.
fmg.asdr. IOhanens
Hi
IOhannes m zmoelnig wrote:
could you try to replace splitfilename.c with the attached file and recompile iemlib2 and look whether this fixes the crash ?
i have also checked my change into the CVS but don't know whether you have access.
Yes, i do. and i used the updated source from there, but unfortunately it doesn't fix the crash. The "free(): invalid pointer 0x8215550!" message doesn't come up anymore upon when it segfaults, however. And the backtrace is kind of different (don't have a clue about what it means, though...)
(gdb) bt #0 0x401ee52d in mallopt () from /lib/libc.so.6 #1 0x401edfcc in mallopt () from /lib/libc.so.6 #2 0x401ed763 in calloc () from /lib/libc.so.6 #3 0x080a2a75 in getbytes (nbytes=2053202479) at m_memory.c:24 #4 0x080a2bc4 in binbuf_text (x=0x821e5a0, text=0xbfffd630 ".x821f758 key 0 105 0 ; 132.0 1 ;3x323+0+0 ; \177\006", size=23) at m_binbuf.c:63 #5 0x080ad955 in socketreceiver_doread (x=0x821e5c0) at s_inter.c:420 #6 0x080abaa8 in socketreceiver_read (x=0x821e5c0, fd=402) at s_inter.c:523 #7 0x080ad71f in sys_domicrosleep (microsec=2053202479, pollem=1) at s_inter.c:177 #8 0x080acdf8 in sys_microsleep (microsec=2053202479) at s_inter.c:196 #9 0x080a855f in m_scheduler () at m_sched.c:487 #10 0x080b2a5b in main (argc=2053202479, argv=0x7a61622f) at s_entry.c:27
hope this makes any sense... johannes
fmg.asdr. IOhanens
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
- WARRANTIES, see the file, "LICENSE.txt," in this distribution.
iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
#ifdef NT #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif
#include "m_pd.h" #include "iemlib.h" #include <stdlib.h> #include <string.h> #include <stdio.h>
/* ----------------------- splitfilename -------------------------- */ /* -- splits a symbol into 2 parts (path + file) at the position -- */ /* -- of the first separator-character beginnig from the right ---- */ /* ---------- eliminating the separator-character ----------------- */
static t_class *splitfilename_class;
typedef struct _splitfilename { t_object x_obj; char x_sep[2]; void *x_outpath; void *x_outfile; } t_splitfilename;
static void splitfilename_separator(t_splitfilename *x, t_symbol *s, int ac, t_atom *av) { if(ac > 0) { if(IS_A_SYMBOL(av, 0)) { if(strlen(av->a_w.w_symbol->s_name) == 1) x->x_sep[0] = av->a_w.w_symbol->s_name[0]; else if(!strcmp(av->a_w.w_symbol->s_name, "backslash")) x->x_sep[0] = '\'; else if(!strcmp(av->a_w.w_symbol->s_name, "slash")) x->x_sep[0] = '/'; else if(!strcmp(av->a_w.w_symbol->s_name, "blank")) x->x_sep[0] = ' '; else if(!strcmp(av->a_w.w_symbol->s_name, "space")) x->x_sep[0] = ' '; else if(!strcmp(av->a_w.w_symbol->s_name, "dollar")) x->x_sep[0] = '$'; else if(!strcmp(av->a_w.w_symbol->s_name, "comma")) x->x_sep[0] = ','; else if(!strcmp(av->a_w.w_symbol->s_name, "semi")) x->x_sep[0] = ';'; else if(!strcmp(av->a_w.w_symbol->s_name, "leftbrace")) x->x_sep[0] = '{'; else if(!strcmp(av->a_w.w_symbol->s_name, "rightbrace")) x->x_sep[0] = '}'; else x->x_sep[0] = '/'; } else if(IS_A_FLOAT(av, 0)) { int i; float f=fabs(av->a_w.w_float); while(f >= 10.0) f *= 0.1; i = (int)f; x->x_sep[0] = (char)i + '0'; } } else x->x_sep[0] = 0; }
static void splitfilename_symbol(t_splitfilename *x, t_symbol *s) { int len = strlen(s->s_name);
if(len) { if(x->x_sep[0] != 0) { char *str_path = (char *)getbytes(len*sizeof(char)); char *str_file = (char *)getbytes(len*sizeof(char)); char *cpp, *cpf; strcpy(str_path, s->s_name); strcpy(str_file, s->s_name); cpp = strrchr(str_path, x->x_sep[0]); cpf = strrchr(str_file, x->x_sep[0]); if(!cpp) /* JMZ: 20050701 */ { outlet_symbol(x->x_outfile, gensym(str_file)); outlet_symbol(x->x_outpath, &s_);
} else if (!cpf) /* JMZ: 20050701 */ { outlet_symbol(x->x_outfile, &s_); outlet_symbol(x->x_outpath, gensym(str_path)); } else if((cpp - str_path) < 0) /* JMZ:removed typecast (char*) to (int); this is not portable */ { outlet_symbol(x->x_outfile, gensym(str_file)); outlet_symbol(x->x_outpath, &s_); } else if((cpp - str_path) >= len) /* JMZ: removed typecast (char*) to (int) */ { outlet_symbol(x->x_outfile, &s_); outlet_symbol(x->x_outpath, gensym(str_path)); } else { *cpp = 0; cpf++; outlet_symbol(x->x_outfile, gensym(cpf)); outlet_symbol(x->x_outpath, gensym(str_path)); } freebytes(str_file, len*sizeof(char)); freebytes(str_path, len*sizeof(char)); } else { outlet_symbol(x->x_outfile, &s_); outlet_symbol(x->x_outpath, s); } } }static void *splitfilename_new(t_symbol *s, int ac, t_atom *av) { t_splitfilename *x = (t_splitfilename *)pd_new(splitfilename_class);
x->x_sep[0] = 0; x->x_sep[1] = 0; if(ac == 0) x->x_sep[0] = '/'; else splitfilename_separator(x, s, ac, av); x->x_outpath = outlet_new(&x->x_obj, &s_symbol); x->x_outfile = outlet_new(&x->x_obj, &s_symbol); return (x); }
void splitfilename_setup(void) { splitfilename_class = class_new(gensym("splitfilename"), (t_newmethod)splitfilename_new, 0, sizeof(t_splitfilename), 0, A_GIMME, 0); class_addsymbol(splitfilename_class, splitfilename_symbol); class_addmethod(splitfilename_class, (t_method)splitfilename_separator, gensym("separator"), A_GIMME, 0); class_addmethod(splitfilename_class, (t_method)splitfilename_separator, gensym("sep"), A_GIMME, 0); class_sethelpsymbol(splitfilename_class, gensym("iemhelp/help-splitfilename")); }