From: Brian G. <bri...@ea...> - 2025-01-05 22:30:07
|
It certainly solves to seg fault for me when I try it. It also eliminates all the compilation warnings. Without the changes, I'm seeing these warnings: get_elements_bug.c:15:44: warning: incompatible pointer types passing 'int *' to parameter of type 'Tcl_Size *' (aka 'long *') [-Wincompatible-pointer-types] 15 | char *str = Tcl_GetStringFromObj(objPtr, &len); | ^~~~ /Users/briang42/tcl_core/usr_mac_special/include/tclDecls.h:1754:15: note: passing argument to parameter 'lengthPtr' here 1754 | Tcl_Size *lengthPtr); | ^ get_elements_bug.c:19:46: warning: incompatible pointer types passing 'int *' to parameter of type 'Tcl_Size *' (aka 'long *') [-Wincompatible-pointer-types] 19 | if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { | ^~~~~ /Users/briang42/tcl_core/usr_mac_special/include/tclDecls.h:1787:33: note: passing argument to parameter 'objcPtr' here 1787 | Tcl_Obj *listPtr, Tcl_Size *objcPtr, | ^ get_elements_bug.c:24:39: warning: format specifies type 'unsigned int' but the argument has type 'Tcl_Obj **' (aka 'struct Tcl_Obj **') [-Wformat] 24 | printf("objc=%d, objv=%016X\n",objc,objv); | ~~~~~ ^~~~ get_elements_bug.c:25:28: warning: format specifies type 'unsigned int' but the argument has type 'Tcl_Obj *' (aka 'struct Tcl_Obj *') [-Wformat] 25 | printf("objv[0]=%016X\n",objv[0]); | ~~~~~ ^~~~~~~ 4 warnings generated. With the corrections I get this result: got string result 'fefe' objc=1, objv=0x1308a0b78 objv[0]=0x120039020 objv[0] = 'fefe' all done Note: I extended the test case to go further. YMMV. -Brian > On Jan 5, 2025, at 11:57, Vadim V Konovalov via Tcl-Core <tcl...@li...> wrote: > > Will that change fix the segmentation fault? > From: Jan Nijtmans <jan...@gm...> > Sent: Sunday, January 5, 2025 9:53 PM > To: Коновалов Вадим Владимирович <vad...@ga...> > Cc: Ashok Nadkarni <apn...@ya...>; Kevin Walzer <kw...@co...>; Marc Culler <cul...@gm...>; Tcl Core List <tcl...@li...> > Subject: Re: [TCLCORE] problems with Tcl/Tk 9.0 in the Perl Tcl module > Op zo 5 jan 2025 om 18:44 schreef Vadim V Konovalov via: > Here is small program to reproduce: > ... int objc,len; In Tcl 9, this line should be: > Tcl_Size objc, len; > Also, for printing pointers, please use "%p" instead of "%016X". The > compiler should give a warning for this! > I don't think this is the cause of your error, but better rule > this out first. > Regards, > Jan Nijtmans > _______________________________________________ > Tcl-Core mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-core |