lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
217 stars 291 forks source link

segmentation fault (core dumped) #36

Closed mandar91thakur closed 8 years ago

mandar91thakur commented 9 years ago

This might appear to be a trivial issue, but I am unable to find the solution because of deficient programming skills. The unmodified explanatory.ini file works fine, but when I modified explanatory.ini by changing write Background = yes , and then execute , I get segmentation fault (core dumped). The detailed description is given below:

mandar@mandar-VirtualBox:~/class_public-2.4.2$ ./class my_input.ini Running CLASS version v2.4.2 Computing background -> age = 13.795359 Gyr -> conformal age = 14165.045412 Mpc Computing thermodynamics with Y_He=0.2477 -> recombination at z = 1089.267451 corresponding to conformal time = 280.576042 Mpc with comoving sound horizon = 144.695940 Mpc angular diameter distance = 12.734921 Mpc and sound horizon angle 100*thetas = 1.042142 -> baryon drag stops at z = 1059.171266 corresponding to conformal time = 286.488461 Mpc with comoving sound horizon rs = 147.376600 Mpc -> reionization with optical depth = 0.092473 corresponding to conformal time = 4255.316282 Mpc Computing sources Computing primordial spectra (analytic spectrum) No non-linear spectra requested. Nonlinear module skipped. Computing transfers Computing unlensed linear spectra Computing lensed spectra (fast mode) Writing output files in output/toto... Segmentation fault (core dumped)

When I analyse the core file by GDB, this appears:

mandar@mandar-VirtualBox:~/class_public-2.4.2$ gdb file core GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: http://bugs.launchpad.net/gdb-linaro/... Reading symbols from /usr/bin/file...(no debugging symbols found)...done.

warning: core file may not match specified executable file. [New LWP 5653] Core was generated by `./class my_input.ini'. Program terminated with signal 11, Segmentation fault.

0 0x0808e954 in ?? ()

ThomasTram commented 9 years ago

Hi Mandar,

thanks for reporting this! This is a bug which will lead to segmentation fault on machines running 32 bit linux through Virtualbox. (At least, that is the only confirmed cases.) The fix is very simple: In line 1166 of source/output.c, you will find the line:

class_alloc(data,sizeof(double*)*size_data,pop->error_message);

It should be changed to

class_alloc(data,sizeof(double)*size_data,pop->error_message);

i.e. remove the star after double. (It's a typo, the allocation should have been of doubles, not double pointers. Most of the time a double pointer will be as big as a double (64 bit) but not always.)

There is another place where the same bug occur, on line 1217, related to thermodynamics output.

Let me know if it works for you.

Cheers, Thomas

mandar91thakur commented 9 years ago

Thanks for the quick reply. I tried the above fix , but unfortunately the problem still persists. Anyways, for the better, I installed 64 bit Ubuntu on Virtualbox and now it works fine. Thanks a ton.

Regards, Mandar