bugGNU Scientific Library - Bugs: bug #58763, gsl_root_fsolver_bren produces...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #58763: gsl_root_fsolver_bren produces wrong results when run under valgrind

Submitter:  Sergei Ossokine <sergei1387>
Submitted:  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

Tue 14 Jul 2020 09:25:00 AM UTC, original submission:  

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

Sergei Ossokine <sergei1387>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #49481:  demo.c added by sergei1387 (1KiB - application/octet-stream - demo.c is the main file demo_fn.* define the quadratic function being used for root finding)
file #49482:  demo_fn.c added by sergei1387 (666B - application/octet-stream - demo.c is the main file demo_fn.* define the quadratic function being used for root finding)
file #49483:  demo_fn.h added by sergei1387 (228B - application/octet-stream - demo.c is the main file demo_fn.* define the quadratic function being used for root finding)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by sergei1387 (Submitted the item)
  •  

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-07-14 sergei1387 Attached File- Added demo.c, #49481
        Attached File- Added demo_fn.c, #49482
        Attached File- Added demo_fn.h, #49483

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code