From: Dietmar W. <die...@ar...> - 2007-09-12 17:22:28
|
Hi Paolo, I just checked in a version of terminal.c which meet my requirements under mingw, MSC and Linux. Sun not tested yet. You are free to modify it. Dietmar Paolo Nenzi schrieb: > Ciao Dietmar, > > Ok then, de-crashing. If we remove additional spaces we just shift the > problem, we do not solve it. The solution is to use asprintf() on UNIX > but is not portable on Windows. The real solution will be to implement > asprintf on windows or, use a utility library that has such kind of > function and is available on Windows, like glib. > > http://library.gnome.org/devel/glib/2.10/glib-String-Utility-Functions.html#g-vasprintf > > Look for other solutions, > Paolo > > > Dietmar Warning wrote: > >> Hi Paolo, >> >> we do not speak about debugging - it is just "crashing". >> The error appears e.g. in long model cards like we have in bsim4. If you >> have a wrong "level=28" parameter the entire model card with about 9k is >> printed and we have a buffer overflow. >> (A work around would be to remove multiple spaces from this string short >> before output. May be we have such kind of function in ngspice?) >> >> Dietmar >> >> Paolo Nenzi schrieb: >> >> >>> Hi guys, >>> >>> Just to see the bug in another perspective. Does it make sense to have a >>> 8kb debugging output ? >>> Why not just print out the first few bytes of debugging and append a >>> "...\0" string to inform that there is a continuation. As I have >>> understood from Dietmar's original message, the debug information >>> printed was a big netlist, correct ? >>> >>> Ciao, >>> Paolo >>> >>> >>> Dietmar Warning wrote: >>> >>> >>> >>>> Hi Charles, >>>> >>>> I like your solution but some compiler (e.g. MSC) give a "-1" and not >>>> the needed size for howMany if the string is larger then the buffer. >>>> (This seems a known problem of snprintf!) >>>> >>>> Dietmar >>>> >>>> >>>> Charles D.H.Williams schrieb: >>>> >>>> >>>> >>>> >>>>> On Sep 11, 2007, at 20:49, ngs...@li... >>>>> wrote: >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>> out_printf >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> My suggestion for a solution to this problem is: >>>>> >>>>> char out_pbuf[BSIZE_SP]; >>>>> >>>>> void out_printf(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) >>>>> char *fmt, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9, *s10; >>>>> { >>>>> int howMany = snprintf(out_pbuf, sizeof(out_pbuf), fmt, s1, s2, s3, >>>>> s4, s5, s6, s7, s8, s9, s10); >>>>> if (howMany<sizeof(out_pbuf)) { >>>>> out_send(out_pbuf); >>>>> } else { >>>>> char *tbuf = tmalloc(howMany+1); >>>>> snprintf(tbuf, howMany+1, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, >>>>> s10); >>>>> out_send(tbuf); >>>>> tfree(tbuf); >>>>> } >>>>> return; >>>>> } >>>>> >>>>> A modification to this would let tbuf persist growing it as necessary. >>>>> (I didn't do this because such behaviour looks like a leak to my >>>>> homespun diagnostics instrumentation.) >>>>> >>>>> Charles >>>>> >>>>> >>>>> ------------------------------------------------------------------------- >>>>> This SF.net email is sponsored by: Microsoft >>>>> Defy all challenges. Microsoft(R) Visual Studio 2005. >>>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>>>> _______________________________________________ >>>>> Ngspice-devel mailing list >>>>> Ngs...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/ngspice-devel >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> ------------------------------------------------------------------------- >>>> This SF.net email is sponsored by: Microsoft >>>> Defy all challenges. Microsoft(R) Visual Studio 2005. >>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>>> _______________________________________________ >>>> Ngspice-devel mailing list >>>> Ngs...@li... >>>> https://lists.sourceforge.net/lists/listinfo/ngspice-devel >>>> >>>> >>>> >>>> >>> ------------------------------------------------------------------------- >>> This SF.net email is sponsored by: Microsoft >>> Defy all challenges. Microsoft(R) Visual Studio 2005. >>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> _______________________________________________ >>> Ngspice-devel mailing list >>> Ngs...@li... >>> https://lists.sourceforge.net/lists/listinfo/ngspice-devel >>> >>> >>> >>> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2005. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Ngspice-devel mailing list >> Ngs...@li... >> https://lists.sourceforge.net/lists/listinfo/ngspice-devel >> >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Ngspice-devel mailing list > Ngs...@li... > https://lists.sourceforge.net/lists/listinfo/ngspice-devel > > |