From: Harry Huang on 18 Mar 2010 18:01 I installed TCL/TK into a hardware. But When I run a TCL program (calling tcl libray API) on the hardward, the program crashed in the TclpAlloc function (malloc function) which is defined as : Char * TclpAlloc(unsigned int numBytes) { return (char*) malloc(numBytes); } The error reported is "Alignment fault at adress xxxxx ...". I checked numBytes is 1024. Anyone have ideas about this ?
From: Alexandre Ferrieux on 18 Mar 2010 18:13 On Mar 18, 11:01 pm, Harry Huang <hhuan...(a)gmail.com> wrote: > I installed TCL/TK into a hardware. But When I run a TCL program > (calling tcl libray API) on the hardward, the program crashed in the > TclpAlloc function (malloc function) which is defined as : > > Char * TclpAlloc(unsigned int numBytes) { > return (char*) malloc(numBytes); > > } > > The error reported is "Alignment fault at adress xxxxx ...". I checked > numBytes is 1024. Anyone have ideas about this ? Most likely heap corruption, done *before* that call. A tool like valgrind, if it is an option on your hardware, might help. Another method, maybe more practical in your case, is to use 'configure -- enable-symbols=mem'. This will instrument internal allocations, and the script-level function [memory validate on] will activate a mode that verifies validity of the whole heap on each malloc/free. Extremely slow but may help. -Alex
From: Harry Huang on 18 Mar 2010 21:56 On 3ÔÂ18ÈÕ, ÏÂÎç6ʱ13·Ö, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> wrote: > On Mar 18, 11:01 pm, Harry Huang <hhuan...(a)gmail.com> wrote: > > > I installed TCL/TK into a hardware. But When I run a TCL program > > (calling tcl libray API) on the hardward, the program crashed in the > > TclpAlloc function (malloc function) which is defined as : > > > Char * TclpAlloc(unsigned int numBytes) { > > return (char*) malloc(numBytes); > > > } > > > The error reported is "Alignment fault at adress xxxxx ...". I checked > > numBytes is 1024. Anyone have ideas about this ? > > Most likely heap corruption, done *before* that call. A tool like > valgrind, if it is an option on your hardware, might help. Another > method, maybe more practical in your case, is to use 'configure -- > enable-symbols=mem'. This will instrument internal allocations, and > the script-level function [memory validate on] will activate a mode > that verifies validity of the whole heap on each malloc/free. > Extremely slow but may help. > > -Alex The interesting thing is it is passed if I used: "return (char*) malloc(1024);". So use a positive integer will be Ok, but use "numBytes" will be failed. Is it possible a "casting" issue ? I remember the call to call "TclpAlloc" is something like " "char * s = TclpAlloc(sizeof(structure) * a )" where a is a 'int'
From: Larry W. Virden on 19 Mar 2010 11:49 On Mar 18, 6:01 pm, Harry Huang <hhuan...(a)gmail.com> wrote: > the program crashed in the > TclpAlloc function (malloc function) which is defined as : > > Char * TclpAlloc(unsigned int numBytes) { > return (char*) malloc(numBytes); > > } > > The error reported is "Alignment fault at adress xxxxx ...". I checked > numBytes is 1024. Anyone have ideas about this ? That's seems a bit peculiar. Normally, a library built for a specific platform should be able to malloc memory that is aligned properly. What I have seen is someone malloc some memory, then later go to use the memory in an operation that required a more stringent alignment than malloc by default gave. For instance, someone might have a system which required a certain data structure, or floating numbers, or an int, etc. to reside on a particular word boundary. This was C code, not Tcl code... The C code would then perform a malloc, take the returned address, and adjust the address to be on the alignment boundary required for the data type being used. Messy.
|
Pages: 1 Prev: 17th annual TCL/TK conference & call for papers Next: showing progress when doing copy |