Archived

This forum has been archived. Please start a new discussion on GitHub.

Freeze example from manual throws DbException

Currently, I'm stuck in section 40.3.7 of the Ice manual 3.2.1 with the Freeze sample program.

After "slice2freeze --dict StringIntMap,string,int StringIntMap" and typing the complete sample code (freeze.cpp), I compile the program with "g++ -I. -o freeze freeze.cpp StringIntMap.cpp -lFreeze" without any problems. Then I create the "db" directory.

When I run "./freeze", the program terminates with this message:
terminate called after throwing an instance of 'DbException'
what(): DbEnv::stream_error: Invalid argument

This seems to be caused by the line "p = map.find("z");".

What am I missing?

Andreas

Comments

  • BTW, OpenSUSE 10.0 has Berkeley DB 4.3.27, and with this version the DbException is thrown. A half-hearted attempt to install BDB 4.6 locally resulted in a slightly different reaction of "freeze.cpp": a plain "memory access error" occurred.

    Freeze examples/demos do compile and execute as expected with my system configuration. Obviously there must be some trick in the demo Makefile(.rules) that my manual attempt doesn't spin correctly.

    Andreas
  • matthew
    matthew NL, Canada
    I just tried this example with Ice 3.2.1 and it works as expected. Did you try to drop the example into one of the Freeze demo subdirectories and build that? If that works then you know its some compiler setting. If not, then it is likely caused by the Berkeley DB version you are using.

    Note that we don't support 4.6 yet. The officially supported version is 4.5.20.
  • matthew wrote: »
    Did you try to drop the example into one of the Freeze demo subdirectories and build that?
    When I copy "freeze.cpp" to ../demo/Freeze/bench/Client.cpp, create StringIntMap as advised, and modify the Makefile accordingly, "make" runs through, but the effect of the resulting program is the same as before, i.e., a DbException is thrown.
    The officially supported version is 4.5.20.
    I also tried the SRPM you provide for download. The effect is the same as with BDB 4.6, i.e., a plain memory access error on startup.

    Andreas
  • I also tried the SRPM you provide for download. The effect is the same as with BDB 4.6, i.e., a plain memory access error on startup.

    Not quite! After unpacking, building, and installing BDB 4.5.20/Ice, plus re-building and re-installing Ice 3.2.1 (after uncommenting the BDB-requirements in ice.spec), the effect of "g++ -I. -o freeze freeze.cpp StringIntMap.cpp -lFreeze" is completely different:
    [ 09/13/07 08:42:18.252 Berkeley DB: DbEnv "db": DB_TXN->abort: log undo failed for LSN: 1 24417: No such file or directory ]
    [ 09/13/07 08:42:18.253 Berkeley DB: DbEnv "db": PANIC: No such file or directory ]
    [ 09/13/07 08:42:18.253 Berkeley DB: DbEnv "db": unable to abort transaction 0x80000056: DB_RUNRECOVERY: Fatal error, run database recovery ]
    [ 09/13/07 08:42:18.253 Berkeley DB: DbEnv "db": PANIC: DB_RUNRECOVERY: Fatal error, run database recovery ]
    [ 09/13/07 08:42:18.254 Berkeley DB: DbEnv "db": Error: closing the transaction region with active transactions ]
    terminate called after throwing an instance of 'Freeze::DatabaseException'
    what(): N6Freeze17DatabaseExceptionE

    Note that the "db" subdirectory does exist, and "freeze" even creates non-empty files "simple", "log.0...01", and "__catalog" in it. This "BDB PANIC" also occurs for the drop-in-replacement of "freeze.cpp" in "demo/Freeze/bench/Client.cpp".

    Andreas
  • matthew
    matthew NL, Canada
    I just realized when I screwed up when I tested against Ice 3.2.1 yesterday. I had worked around the problem in the source, and then accidentally tested the workaround on 3.2.1 instead of the problematic source. Woops.

    I think this is a bug in Freeze. However, you can easily work around it by scoping the map such that it is destroyed before the connection is closed. If you need more assistance please let us know!
  • Aha! Adding two curly braces and all is well. :)

    Thanks,
    Andreas