bug-libmatheval
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-libmatheval] segmentation fault using matheval


From: Aleksandar B. Samardzic
Subject: Re: [Bug-libmatheval] segmentation fault using matheval
Date: Fri, 30 Jul 2004 21:56:12 +0200
User-agent: Mutt/1.4.2.1i

On Fri, Jul 30, 2004 at 12:18:49PM +0200, Ferrarese Leopoldo wrote:
> 
> Hi,
> 
> >Thanks for the problem report.  There exist no global variables in
> >library so it should be fully thread-safe.  Could you please try
> >problematic functions with test program utilizing your function that I'm
> >attaching to this message and then let me know of input that will make
> >problem to appear?  Regarding segfaulting - I hope you allocated large
> >enough buffer for res argument (would suggest using snprintf() instead
> >of sprintf() anyway)?  Further, evaluator_create() will return NULL if
> >string passed to this function is invalid regarding allowed syntax (see
> >evaluator_create() node in library documentation for explanation what is
> >allowed).
> >Regards,
> >Alex
> 
> Thank you, for the code, but I haven't a problem with the lenght of the 
> string buffer.
> I think to isolate an input case, and I investigate:
> if use correct function, all is ok.
> but when I use "log(2)^^2", in this case the first evaluator_create failed, 
> ok, is correct, 
> but all the next functions fail!

Must confess I still don't understand problem exactly.  If
evaluator_create() returned NULL, you should issue an error message to
user stating that syntax of his expression is wrong and you shouldn't
call any other function before calling evaluator_create() again
(presumably with corrected expression passed).  Specifically, if
evaluator_create() returned NULL, you shouldn't call evaluator_destroy()
with NULL as an argument.

 
> Now I think to resolv the problem in this way:
> 1) in main function,I create a pointer with a simple function:
> function_safe=evaluator_create("1+1\0");
> 2) in calcola function if evaluator_create failed, I call the 
> evaluator_destroy(function_safe);
> 3) recall the function_safe=evaluator_create("1+1\0");
> 
> I don't know why.. but this solution works...
> :)
> 
> there isn't a function to initializate all???

Could you eventually supply a piece of C code like one I supplied in my
previous message (preferably your CGI program stripped), that would help
me to understand how exactly are you manipulating with evaluators?

 
> If you want try were I use the matheval, follow this link:
> http://search.virgilio.it/search/cgi/search.cgi?f=hv&switch=0&offset=0&hits=10&qs=1%2B1
> 

Seems like nice idea, let's try to agree upon how would you exactly
expect libmatheval to behave in case of invalid input so that you could
complete your application.

Regards,
Alex





reply via email to

[Prev in Thread] Current Thread [Next in Thread]