pointer, core dump error

General FreeBASIC programming questions.
Helium5793
Posts: 14
Joined: Jun 21, 2016 13:06

pointer, core dump error

Postby Helium5793 » Feb 10, 2020 18:50

I am getting this at the end of a short program that just loads some data.
munmap_chunk(): invalid pointer
munmap_chunk(): invalid pointer
Aborted (core dumped)

The program that is doing this is:[

Code: Select all

declare sub write_reagent()
declare sub read_reagent()

DIM SHARED as integer k, reag_count
DIM SHARED as string reag_name(200), reag_density(200), reag_code(200), reag_unit(200)

DIM SHARED as double reag_year(200), reag_inventory(k), reag_price(200), reag_mw(200)

SCREEN 0
'COLOR 0, 7

read_reagent()
'write_reagent()




SUB read_reagent()
cls
    OPEN "reagent-new.dat" FOR INPUT AS #3

    INPUT #3, reag_count
    PRINT reag_count
    FOR k = 1 TO reag_count
        INPUT #3, reag_name(k), reag_density(k), reag_code(k), reag_unit(k), reag_year(k), reag_inventory(k), reag_price(k), reag_mw(k)
         PRINT reag_name(k), reag_density(k), reag_code(k), reag_unit(k), reag_year(k), reag_inventory(k), reag_price(k), reag_mw(k)

    NEXT
    CLOSE #3
END SUB

/'SUB write_reagent()

    OPEN "reagent-new-test.dat" FOR OUTPUT AS #3
   WRITE #3, reag_count
   FOR k = 1 TO reag_count
   
   WRITE #3, reag_name(k), reag_density(k), reag_code(k),reag_unit(k), reag_year(k), reag_inventory(k), reag_price(k), reag_mw(k)
   
    PRINT reag_name(k), reag_density(k), reag_code(k), reag_year(k), reag_inventory(k), reag_price(k), reag_mw(k)
    NEXT
    CLOSE #3
END SUB'/


and the data file that it is reading is:
28
"water ","1 ","W001 ","kg",0,23,0.02,18.01
"t-butanol ",".775 ","T001 ","kg",0,2.933375,10,74.12
"acetyl chloride ","1.104 ","A001 ","kg",0,4.17864,10,78.5
"dimethylaniline ",".956 ","A002 ","kg",0,3.61846,50,121.18
"diethylether ",".715 ","E001 ","kg",0,0.715,2,74.12
"10% sulfuric acid ","1.084 ","S001 ","kg",0,4.10294,10,98.08
"NaOH (50% sol'n) ","1.530 ","S002 ","kg",0,5.79105,12,40
"sat'd sodium bicarbonate ","1.1 ","S003 ","kg",0,4.1635,5,84.011
"sodium sulfate (anhy) ","s ","S004 ","kg",0,1,5,142.04
"t-butylacetate ",".862 ","A003 ","kg",0,0.862,25,116.16
"dimethylaniline HCl ","S ","A004 ","kg",0,0,45,157.63
"methyl acrylate ",".894 ","A005 ","kg",0,0.894,50,128.17
"n-butanol ","0.81 ","B002 ","kg",0,3.06585,12,74.12
"hydroquinone ","S ","H001 ","kg",0,1,25,110.11
"p-toluenesulfonic acid:H2O","S ","S005 ","kg",0,1,25,190.22
"FeSO4:7H2O ","S ","I001 ","kg",0,1,5,278.015
"HCl (37w/w%) ","1.2 ","H002 ","kg",0,4.542,12,36.458
"o-nitrobenzaldehyde ","S ","N001 ","kg",0,1,30,151.12
"NH4OH (conc) ",".90 ","A006 ","kg",0,3.4065,18,35.0468
"sodium chloride ","S ","S006 ","kg",0,1,5,58.44
"o-aminobenzaldehyde ","S ","A007 ","kg",0,1,100,121.132
"acetic acid ","1.049 ","A008 ","kg",0,19.85233,12,60.05
"acetic anhydride ","1.082 ","A009 ","kg",0,3.246,5,102.09
"pyridine ",".978 ","P001 ","kg",0,3.70173,10,79.0999
"bromine ","3.102 ","B003 ","kg",0,3.102,100,159.82
"bromoacetic acid ","S ","B004 ","kg",0,1,45,138.95
"ethanol ",".794 ","E002 ","kg",0,3.00529,12,46.07
"sulfuric acid ","1.84 ","S010 ","kg",0,10,1,98.08

The program compiles ok; when run it prints the data properly, and coughs up the errors.

munmap_chunk(): invalid pointer
munmap_chunk(): invalid pointer
Aborted (core dumped)
any idea where the errors are coming from? I am running fedora 31 linux

any help appreciated
John

EDITED by Moderator to add code and quote blocks.
fxm
Posts: 9470
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: pointer, core dump error

Postby fxm » Feb 10, 2020 22:34

DIM SHARED as double reag_year(200), reag_inventory(k), reag_price(200), reag_mw(200)
DIM SHARED as double reag_year(200), reag_inventory(200), reag_price(200), reag_mw(200)
Imortis
Moderator
Posts: 1667
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: pointer, core dump error

Postby Imortis » Feb 10, 2020 22:39

@fxm:
Faster than me. I was going to say the same thing, but wanted to test to make sure that was correct.

@Helium5793:
Welcome to the forum! Just as a note, when posting code, please use the [ code ][ /code ] (without the spaces) tags to keep it neat and easy on the eyes.
badidea
Posts: 1779
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: pointer, core dump error

Postby badidea » Feb 10, 2020 23:43

If you compile with -exx, you often get a more useful error message then 'core dumped' when running the code.
Helium5793
Posts: 14
Joined: Jun 21, 2016 13:06

Re: pointer, core dump error

Postby Helium5793 » Feb 13, 2020 17:08

Thank you all for your replies. I appreciate the help. I am new here and am running across a couple more problems . First when I compile successfully I am getting 2 error messages. (I have installed fbc in fedora 31 64bit following the directions on github.com) I am using geany as the ide.

the error messages are: fbc: /lib64/libtinfo.so.5: no version information available (required by fbc)
and fbc: Symbol 'ospeed' has a different size in shared object, consider re-linking

libtinfo.so.5 is on this computer, but it is in /usr/lib64.
No ideas on the second error.

anyway, are these messages important, and how can I fix them?

Also, It appears that filenames are limited to 8 characters.xxx. Is that right? I am loading a simple csv file and it does not load or give an error if the file name is 'element-new.indx' but does load if the filename is element.txt I have looked into the docs but have not found any comments on filenames. Doesn't mean they were not there, but that I couldn't locate them.
I appreciate any help,
Thanks,
John
Imortis
Moderator
Posts: 1667
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: pointer, core dump error

Postby Imortis » Feb 13, 2020 17:17

https://www.freebasic.net/forum/viewtopic.php?f=5&t=11217

Check the above topic. There may be some extra .so files you will need. It is also possible that FBC needs a different version of the library than the one you have installed.
Helium5793
Posts: 14
Joined: Jun 21, 2016 13:06

Re: pointer, core dump error

Postby Helium5793 » Feb 13, 2020 18:28

Ok, thank you. I will do that. I went back to my original code. I overlooked that 'k' for days, maybe weeks. I really appreciate all of you being an extra set of eyes on that one.
John
badidea
Posts: 1779
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: pointer, core dump error

Postby badidea » Feb 13, 2020 18:52

You are not the first with libtinfo.so.5 problems, so e.g.: viewtopic.php?f=5&t=27900&p=264779&hilit=libtinfo.so.5#p264779
Helium5793
Posts: 14
Joined: Jun 21, 2016 13:06

Re: pointer, core dump error

Postby Helium5793 » Feb 13, 2020 20:53

I figured out my filename issue. No dashes allowed. I replaced the dashes with underline and the longer filenames are working. It is curious that an illegal filename did cough up an error message though.

I am checking the links you guys are giving me. I did find out ospeed is a variable in ncurses and it is libtinfo is also ncurses. I tried to reinstall ncurses which was a near disaster, but I got it fixed. Didn't change the error messages.
Helium5793
Posts: 14
Joined: Jun 21, 2016 13:06

Re: pointer, core dump error

Postby Helium5793 » Feb 13, 2020 21:08

this libtinfo thing gets weirder. I find that fedora has several copies of it around, one in the correct directory for fbc to see it. /lib64 So I guess the question is why isn't it seeing it.
John
MrSwiss
Posts: 3348
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: pointer, core dump error

Postby MrSwiss » Feb 13, 2020 21:20

Is your OS 32 or 64 bit (FBC 64 won't work on 32 bit OS)?
Are you using FBC 32 or 64?
The required lib's must have the same bitness, as the compiler used!

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest