Recent

Author Topic: [gdbm] - Access Violation masquerading as another Exception, needs resport?  (Read 350 times)

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 914
  • Professional amateur ;-P
Hey Y'all,

I've been playing around with the GNU DBM key/value pair database.

You can find some examples on how to do it under the FPC source on the packages/gdbm/examples folder.
As a disclaimer I haven't compiled nor ran those examples.

Nonetheless, I did copy the code, almost verbatim to my TestGNUDBM playground project.

The issue is that on the line that retrieves the last of the keys with gdbm_nextkey() it throws and Access Violation exception.

Code: Pascal  [Select][+][-]
  1. try
  2.   key:= gdbm_nextkey(FDB, key);
  3. except
  4.   on E: Exception do
  5.   begin
  6.     memLog.Append(Format('ERROR: %s', [E.Message]));
  7.     memLog.Append('Need to report this error triggered on the last entry');
  8.     key:= '';
  9.   end;
  10. end;

In debug, if you continue running the program it then issues another exception with the following text -ish:

Code: Text  [Select][+][-]
  1. ### Not supported on GDB < 5.3 ###

Can the experts please tell me if this is a known issue so I don't duplicate an issue posting?

At the moment I'm gobbling up the exception so my code doesn't completely break, as you can see on the GitHub repo source code.
I would like not to have to do it. Even if traversing the whole database is not the most common way to use a key/value pair store.

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10291
  • FPC developer.
Sounds to me as the gdbm header is outdated. There is not much use of gdbm, so that wouldn't surprise me. Most people opt for postgres, firebird, mysql or sqlite

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 914
  • Professional amateur ;-P
Hey Marco,

Sounds to me as the gdbm header is outdated.

Thanks! So what should I do next?

There is not much use of gdbm, so that wouldn't surprise me. Most people opt for postgres, firebird, mysql or sqlite

I completely agree with you, but when you're messing about with pure key/value pair databases, Free Pascal is rather lacking support on the new kid on the block: LevelDB.

To be honest, GDBM was the only thing supported out of the box :)

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

 

TinyPortal © 2005-2018