freebasic / fbfrog

FreeBASIC binding creation tool
Other
34 stars 17 forks source link

Null pointer acces / segfault in util-has.bs #1

Closed StringEpsilon closed 8 years ago

StringEpsilon commented 8 years ago

Compiled with FreeBASIC Compiler - Version 1.05.0 (11-01-2015), built for linux-x86_64 (64bit).

I get a null-pointer access on line 53 in util-hash.bas

==5959== Command: ./fbfrog
==5959== 

Aborting due to runtime error 7 (null pointer access) at line 53 of util-hash.bas::GROWTABLE()

Fixing that by checking "item" for being 0, I get this:

==6959== Command: ./fbfrog
==6959== 
==6959== Invalid read of size 8
==6959==    at 0x46036C: THASH::GROWTABLE() (util-hash.bas:53)
==6959==    by 0x460508: THASH::LOOKUP(char*, unsigned int) (util-hash.bas:69)
==6959==    by 0x46093D: THASH::CONTAINS(char*, unsigned int) (util-hash.bas:128)
==6959==    by 0x4696BC: FBKEYWORDSINIT (util.bas:539)
==6959==    by 0x47AAEC: __libc_csu_init (in /home/user/fbfrog/fbfrog)
==6959==    by 0x57E059E: (below main) (in /usr/lib/libc-2.22.so)
==6959==  Address 0x18 is not stack'd, malloc'd or (recently) free'd
==6959== 
==6959== 
==6959== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==6959==    at 0x55B3C39: raise (in /usr/lib/libpthread-2.22.so)
==6959==    by 0x57F367F: ??? (in /usr/lib/libc-2.22.so)
==6959==    by 0x46036B: THASH::GROWTABLE() (util-hash.bas:53)
==6959==    by 0x460508: THASH::LOOKUP(char*, unsigned int) (util-hash.bas:69)
==6959==    by 0x46093D: THASH::CONTAINS(char*, unsigned int) (util-hash.bas:128)
==6959==    by 0x4696BC: FBKEYWORDSINIT (util.bas:539)
==6959==    by 0x47AAEC: __libc_csu_init (in /home/user/fbfrog/fbfrog)
==6959==    by 0x57E059E: (below main) (in /usr/lib/libc-2.22.so)

I tried writing a fix, but since I don't fully understand your code and the obvious did not work, I feared I might do more harm than good.

dkl commented 8 years ago

Hi,

this should be fixed by commit 0c9ac2e1d24b5215418efcf9ab16118d5d7bb5ed now.

There was a problem in the fbkeywords code, but it only showed up if compiling with fbc -gen gcc (for example 64bit). Thanks for reporting it.