wait command without argument corrupts ODB

Issue #155 closed
Thomas Lindner created an issue

Using the wait command in obdedit without providing any argument seems to corrupt the ODB.

[local:macdaq:S]/>wait Waiting for key "root" to be modified, abort with any key ^CThomass-MacBook-Pro-3:online lindner$ odbedit [ODBEdit,ERROR] [odb.c:1354:db_open_database,ERROR] Invalid, incompatible or corrupted database: root key type 0 is not TID_KEY [ODBEdit,ERROR] [midas.c:2154:cm_connect_experiment1,ERROR] cannot open database Unexpected error #326

This problem is reproducible on Centos 7 and MacOS 10.13.

Using the wait command with an argument does not show this problem:

[local:macdaq:S]/>wait "/Runinfo/Online Mode" Waiting for key "Online Mode" to be modified, abort with any key ^CThomass-MacBook-Pro-3:online lindner$ odbedit [local:macdaq:S]/>

Comments (4)

  1. dd1

    Confirmed on ladd00 (el6):

    <pre> [ODBEdit,ERROR] [odb.c:2558:db_create_key,ERROR] cannot create '/Logger/Message file' in '/' tid is 0, not a directory [ODBEdit,ERROR] [odb.c:3081:db_find_key,ERROR] hkey 200768 path '/' invalid key type 0 </pre>

    After it is corrupted:

    <pre> ladd00:midas$ ./linux/bin/odbedit [ODBEdit,ERROR] [odb.c:1354:db_open_database,ERROR] Invalid, incompatible or corrupted database: root key type 0 is not TID_KEY [ODBEdit,ERROR] [midas.c:2154:cm_connect_experiment1,ERROR] cannot open database Unexpected error #326 </pre>

  2. dd1

    Fixed in commit 2a76627. The bug was in odbedit: db_open_record() does not permit hKey value zero and data buffer supplied to db_open_record() was too small. (fixed size instead of allocated per size returned from db_get_record_size(). In turn, corruption of ODB was caused by lack of and by incorrect validation of hKey values. Specifically db_validate_hkey() must reject value zero because following code does "KEY key = pheader+hkey" which yields a KEY pointing to pheader. K.O.

  3. Stefan Ritt

    I added an additional check directly in odbedit, to not allow "wait" to be called without a key name. Also added this parameter check to a few other commands.

  4. Log in to comment