MESAHub / mesa

Modules for Experiments in Stellar Astrophysics
http://mesastar.org
GNU Lesser General Public License v2.1
138 stars 38 forks source link

Uninitialized variable in burn_1_zone_const_P() #726

Closed pmocz closed 4 weeks ago

pmocz commented 1 month ago

Describe the bug

The array element rpar(r_burn_const_P_rho) is not set around these lines.

https://github.com/MESAHub/mesa/blob/e29ed74db65f919404919714f058f6ea18cde072/net/private/net_burn_const_p.f90#L198

This uninitialized value is used in:

https://github.com/MESAHub/mesa/blob/801e91d0becc3e0a8d6a1b278729a6668cedaa10/num/private/mod_rosenbrock.f#L787

In the ***approx21_cr60_plus_co56*** : test_one_zone_burn_const_P net module test, log10(rpar(r_burn_const_P_rho)) is undefined, because rpar(r_burn_const_P_rho)=0.0 (since my compiler sets uninitialized values to 0 but in general it could be any value with other compilers) :

https://github.com/MESAHub/mesa/blob/e29ed74db65f919404919714f058f6ea18cde072/net/test/src/mod_one_zone_burn.f90#L1026

It's not clear if rpar(r_burn_const_P_rho) is always set by the time it is used to set another variable ending_rho here:

https://github.com/MESAHub/mesa/blob/e29ed74db65f919404919714f058f6ea18cde072/net/private/net_burn_const_p.f90#L229

To Reproduce Steps to reproduce the behavior: Compile with compiler flags -Wall -Wextra -Wimplicit-interface -Wno-unused-function -fPIC -g -fcheck=all,no-array-temps -fbacktrace -ffpe-trap=invalid,zero,overflow -finit-real=snan -finit-integer=-99999999 to catch issues like this

Expected behavior All values are initialized

Desktop (please complete the following information):