Dear all,
I am using Pd version 0.39-2 on linux debian.
I wanted to produce using the makefilename object a symbol that contains a number and a symbol (123test.mtx), by giving the makefilename the wrong %%order my whole pd crashed immediately, producing a segmentation fault. attached is the test patch with explanations.
gdb) run Starting program: /usr/bin/pd (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) [Thread debugging using libthread_db enabled] [New Thread -1211230528 (LWP 3203)] (no debugging symbols found) (no debugging symbols found)
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1211230528 (LWP 3203)] 0xb7d4e783 in strlen () from /lib/tls/libc.so.6 (gdb) where #0 0xb7d4e783 in strlen () from /lib/tls/libc.so.6 #1 0xb7d22064 in vfprintf () from /lib/tls/libc.so.6 #2 0xb7d3acdb in vsprintf () from /lib/tls/libc.so.6 #3 0xb7d272ee in sprintf () from /lib/tls/libc.so.6 #4 0x080eac55 in change_setup () #5 0xbfdd66ac in ?? () #6 0x082368d0 in ?? () #7 0x00000800 in ?? () #8 0xffffffff in ?? () #9 0x037f0f7f in ?? () #10 0x00000000 in ?? () (gdb) quit The program is running. Exit anyway? (y or n) y
Gerda
#N canvas 0 0 629 557 10; #X obj 107 369 print; #X msg 107 250 set $1; #X obj 107 341 makefilename; #X msg 118 302 2048; #X obj 107 221 makefilename %d%%s.mtx; #X msg 107 157 symbol test; #X text 93 63 first press symbol , then after pressing the number message , pd crashes; #X text 276 221 (i know it should be %%d%s.mtx); #X text 97 117 I wanted to create 2048test.mtx; #X connect 1 0 2 0; #X connect 2 0 0 0; #X connect 3 0 2 0; #X connect 4 0 1 0; #X connect 5 0 4 0;
Gerda Strobl wrote:
Dear all,
I am using Pd version 0.39-2 on linux debian.
I wanted to produce using the makefilename object a symbol that contains a number and a symbol (123test.mtx), by giving the makefilename the wrong %%order my whole pd crashed immediately, producing a segmentation fault.
this is one of those "is it really a bug" bugreports.
assuming that [makefilename] is just an interface to a low level C-string formatting, this behaviour is pretty much expected: you are dealing with pointers (%s) which you are setting to a non-sense value (a number) which is always a dangerous thing to do. the relevant part in the help patch reads: 'If you put "%s" in the string be sure to send it a symbol and vice versa... there's no checking.' i guess no checking is done to keep the objects code trivial (i wouldn't want to implement a type-checker for C format strings)
however, since [makefilename] is one of the few built-in objects that allow a bit more sophisticated symbol generation, it could be argued that this object should be made failsafe.
since the object is really primitive right now (you cannot have multiple wildcards (list input!) except for special "lucky" cases), i would suggest the latter.
the good news is, that you can do most of [makefilename]s functionality with the extended super-cow features of the $-arg expansion in pd-0.40
e.g. the (non-existant) [makefilename %d-%s] (currently you have to stack 2 [makefilename]s to get this) can be written as simple as [$1-$2( however, if you want to do more formatting ("%05d") you still have to use [makefilename]
mfg.adr. IOhannes
On Wed, 20 Sep 2006, IOhannes m zmoelnig wrote:
this is one of those "is it really a bug" bugreports. assuming that [makefilename] is just an interface to a low level C-string formatting, this behaviour is pretty much expected:
I don't think so because every other sprintf wrapper in any non-Pd language that I know, is expected to report errors instead of crashing. This includes Perl, Python, Ruby, Tcl, PHP, and *many* more.
you are dealing with pointers (%s) which you are setting to a non-sense value (a number) which is always a dangerous thing to do.
In C/C++, it's a dangerous thing to do; in everything else it's at the same time non-sense and *safe*.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada
Wow, I'll have to check out that feature. what a time saver!
~Kyle
On 9/20/06, IOhannes m zmoelnig zmoelnig@iem.at wrote:
the good news is, that you can do most of [makefilename]s functionality with the extended super-cow features of the $-arg expansion in pd-0.40
e.g. the (non-existant) [makefilename %d-%s] (currently you have to stack 2 [makefilename]s to get this) can be written as simple as [$1-$2( however, if you want to do more formatting ("%05d") you still have to use [makefilename]