URL: <https://savannah.gnu.org/bugs/?58763>
Summary: gsl_root_fsolver_bren produces wrong results when run under valgrind Project: GNU Scientific Library Submitted by: sergei1387 Submitted on: Tue 14 Jul 2020 09:25:00 AM UTC Category: Runtime error Severity: 3 - Normal Operating System: Status: None Assigned to: None Open/Closed: Open Release: 2.5 Discussion Lock: Any _______________________________________________________ Details: When running with valgrind to check for memory leaks, the solver incorrectly sets x_lower and x_upper which results in it exiting immediately without finding a root. This happens even with the basic demo program for 1D root-finding. This does not happen for the other 2 types of solvers, namely gsl_root_fsolver_bisection and gsl_root_fsolver_falsepos. Here is the example of the expected program output (no valgrind): $ ./demo using brent method iter [ lower, upper] root err err(est) 1 [1.0000000, 5.0000000] 1.0000000 -1.2360680 4.0000000 2 [1.0000000, 3.0000000] 3.0000000 +0.7639320 2.0000000 3 [2.0000000, 3.0000000] 2.0000000 -0.2360680 1.0000000 4 [2.2000000, 3.0000000] 2.2000000 -0.0360680 0.8000000 5 [2.2000000, 2.2366300] 2.2366300 +0.0005621 0.0366300 Converged: 6 [2.2360634, 2.2366300] 2.2360634 -0.0000046 0.0005666 And here is running with valgrind: valgrind ./demo ==14950== Memcheck, a memory error detector ==14950== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==14950== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==14950== Command: ./demo ==14950== using brent method iter [ lower, upper] root err err(est) Converged: 1 [5.0000000, 5.0000000] 5.0000000 +2.7639320 0.0000000 ==14950== ==14950== HEAP SUMMARY: ==14950== in use at exit: 0 bytes in 0 blocks ==14950== total heap usage: 2 allocs, 2 frees, 112 bytes allocated ==14950== ==14950== All heap blocks were freed -- no leaks are possible ==14950== ==14950== For counts of detected and suppressed errors, rerun with: -v ==14950== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) The code was compiled with gcc -g -Wall -O2 demo.c -o demo -lgsl -lgslcblas -lm using gcc version 10.1.0 _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Tue 14 Jul 2020 09:25:00 AM UTC Name: demo.c Size: 1KiB By: sergei1387 demo.c is the main file demo_fn.* define the quadratic function being used for root finding <http://savannah.gnu.org/bugs/download.php?file_id=49481> ------------------------------------------------------- Date: Tue 14 Jul 2020 09:25:00 AM UTC Name: demo_fn.c Size: 666B By: sergei1387 demo.c is the main file demo_fn.* define the quadratic function being used for root finding <http://savannah.gnu.org/bugs/download.php?file_id=49482> ------------------------------------------------------- Date: Tue 14 Jul 2020 09:25:00 AM UTC Name: demo_fn.h Size: 228B By: sergei1387 demo.c is the main file demo_fn.* define the quadratic function being used for root finding <http://savannah.gnu.org/bugs/download.php?file_id=49483> _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?58763> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/