| ID |
Date |
Author |
Topic |
Subject |
|
676
|
26 Nov 2009 |
Konstantin Olchanski | Bug Report | once in 100 years midas shared memory bug | We were debugging a strange problem in the event builder, where out of 14
fragments, two fragments were always getting serial number mismatches and the
serial numbers were not sequentially increasing (the other 12 fragments were
just fine).
Then we noticed in the event builder debug output that these 2 fragments were
getting assigned the same buffer handle number, despite having different names -
BUF09 and BUFTPC.
Then we looked at "ipcs", counted the buffers, and there are only 13 buffers for
14 frontends.
Aha, we went, maybe we have unlucky buffer names, renamed BUFTPC to BUFAAA and
everything started to work just fine.
It turns out that the MIDAS ss_shm_open() function uses "ftok" to convert buffer
names to SystemV shared memory keys. This "ftok" function promises to create
unique keys, but I guess, just not today.
Using a short test program, I confirmed that indeed we have unlucky buffer names
and ftok() returns duplicate keys, see below.
Apparently ftok() uses the low 16 bits of the file inode number, but in our
case, the files are NFS mounted and inode numbers are faked inside NFS. When I
run my test program on a different computer, I get non-duplicate keys. So I
guess we are double unlucky.
Test program:
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
int main(int argc, char* argv[])
{
//key_t ftok(const char *pathname, int proj_id);
int k1 = ftok("/home/t2kdaq/midas/nd280/backend/.BUF09.SHM", 'M');
int k2 = ftok("/home/t2kdaq/midas/nd280/backend/.BUFTPC.SHM", 'M');
int k3 = ftok("/home/t2kdaq/midas/nd280/backend/.BUFFGD.SHM", 'M');
printf("key1: 0x%08x, key2: 0x%08x, key3: 0x%08x\n", k1, k2, k3);
return 0;
}
[t2kfgd@t2knd280logger ~/xxx]$ g++ -o ftok -Wall ftok.cxx
[t2kfgd@t2knd280logger ~/xxx]$ ./ftok
key1: 0x4d138154, key2: 0x4d138154, key3: 0x4d138152
Also:
[t2kfgd@t2knd280logger ~/xxx]$ ls -li ...
14385492 -rw-r--r-- 1 t2kdaq t2kdaq 8405052 Nov 24 17:42
/home/t2kdaq/midas/nd280/backend/.BUF09.SHM
36077906 -rw-r--r-- 1 t2kdaq t2kdaq 67125308 Nov 26 10:19
/home/t2kdaq/midas/nd280/backend/.BUFFGD.SHM
36077908 -rw-r--r-- 1 t2kdaq t2kdaq 8405052 Nov 25 15:53
/home/t2kdaq/midas/nd280/backend/.BUFTPC.SHM
(hint: print the inode numbers in hex and compare to shm keys printed by the
program)
K.O. |
|
3200
|
05 Feb 2026 |
Konstantin Olchanski | Bug Report | omnibus bugs from running DarkLight | We finished running the DarkLight experiment and I am reporting accumulated bugs that we have run into.
1) history plots on 12 hrs, 24 hrs tend to hang with "page not responsive". most plots have 16-20 variables,
which are recorded at 1/sec interval. (yes, we must see all the variables at the same time and yes, we want to
record them with fine granularity).
2) starting runs gets into a funny mode if a GEM frontend aborts (hardware problems), transition page reports
"wwrrr, timeout 0", and stays stuck forever, "cancel transition" does nothing. observe it goes from "w"
(waiting) to "r" (RPC running) without a "c" (connecting...) and timeout should never be zero (120 sec in
ODB).
3) ODB editor clicking on hex number versus decimal number no longer allows editing in hex, Stefan implemented
this useful feature and it worked for a while, but now seems broken.
4) ODB editor "right click" to "delete" or "rename" key does not work, the right-click menu disappears
immediately before I can use it (dl-server-2), click on item (it is now blue), right-click menu disappears
before I can use it (daq17). it looks like a timing or race condition.
5) ODB editor "create link" link target name is limited to 32 bytes, links cannot be created (dl-server-2), ok
on daq17 with current MIDAS.
6) MIDAS on dl-server-2 is "installed" in such a way that there is no connection to the git repository, no way
to tell what git checkout it corresponds to. Help page just says "branch master", git-revision.h is empty. We
should discourage such use of MIDAS and promote our "normal way" where for all MIDAS binary programs we know
what source code and what git commit was used to build them.
6a) MIDAS on dl-server-2 had a pretty much non-functional history display, I reported it here, Stefan provided
a fix, I manually retrofitted it into dl-server-2 MIDAS and we were able to run the experiment. (good)
6b) bug (5) suggests that there is more bugs being introduced and fixed without any notice to other midas
users (via this forum or via the bitbucket bug tracker).
K.O. |
|
3201
|
06 Feb 2026 |
Stefan Ritt | Bug Report | omnibus bugs from running DarkLight | Thanks for the detailed report. Let me reply one-by-one.
> 1) history plots on 12 hrs, 24 hrs tend to hang with "page not responsive". most plots have 16-20 variables,
> which are recorded at 1/sec interval. (yes, we must see all the variables at the same time and yes, we want to
> record them with fine granularity).
Attached is a similar plot. 8 values recorded every second, displayed for 24h. The backend is actually a Raspberry Pi! I see no issues there. Do you have
the current history version which does the re-binning? Actually the plot below is still without rebinding (see the "1" at the top right), and it contains ~72000 points x 8. The browser does not have any issue
with it.
Stefan |
| Attachment 1: Lakeshore-Temperatures_A-20260204-120628-20260205-120628.png
|
|
|
3202
|
06 Feb 2026 |
Stefan Ritt | Bug Report | omnibus bugs from running DarkLight | > 3) ODB editor clicking on hex number versus decimal number no longer allows editing in hex, Stefan implemented
> this useful feature and it worked for a while, but now seems broken.
I cannot confirm. See below. There was some issue some time ago, but that's fixed since a while. Please pull on develop and try again.
Here is the change: https://bitbucket.org/tmidas/midas/commits/882974260876529c43811c63a16b4a32395d416a
Stefan |
| Attachment 1: Screenshot_2026-02-06_at_12.44.16.png
|
|
|
3203
|
06 Feb 2026 |
Stefan Ritt | Bug Report | omnibus bugs from running DarkLight | > 4) ODB editor "right click" to "delete" or "rename" key does not work, the right-click menu disappears
> immediately before I can use it (dl-server-2), click on item (it is now blue), right-click menu disappears
> before I can use it (daq17). it looks like a timing or race condition.
Confirmed and fixed: https://bitbucket.org/tmidas/midas/commits/4ba30761683ac9aa558471d2d2d35ce05e72096a
/Stefan |
|
3204
|
06 Feb 2026 |
Stefan Ritt | Bug Report | omnibus bugs from running DarkLight | > 5) ODB editor "create link" link target name is limited to 32 bytes, links cannot be created (dl-server-2), ok
> on daq17 with current MIDAS.
Works for me with the current version.
> 6) MIDAS on dl-server-2 is "installed" in such a way that there is no connection to the git repository, no way
> to tell what git checkout it corresponds to. Help page just says "branch master", git-revision.h is empty. We
> should discourage such use of MIDAS and promote our "normal way" where for all MIDAS binary programs we know
> what source code and what git commit was used to build them.
Not sure if you have seen it. I make a "install" script to clone, compile and install midas. Some people use this already. Maybe give it a shot. Might need
adjustment for different systems, I certainly haven't covered all corner cases. But on a RaspberryPi it's then just one command to install midas, modify
the environment, install mhttpd as a service and load the ODB defaults. I know that some people want it "their way" and that's ok, but for the novice user
that might be a good starting point. It's documented here: https://daq00.triumf.ca/MidasWiki/index.php/Install_Script
The install script is plain shell, so should be easy to be understandable.
> 6a) MIDAS on dl-server-2 had a pretty much non-functional history display, I reported it here, Stefan provided
> a fix, I manually retrofitted it into dl-server-2 MIDAS and we were able to run the experiment. (good)
>
> 6b) bug (5) suggests that there is more bugs being introduced and fixed without any notice to other midas
> users (via this forum or via the bitbucket bug tracker).
If I would notify everybody about a new bug I introduced, I would know that it's a bug and I would not introduce it ;-)
For all the fixes I encourage people to check the commit log. Doing an elog entry for every bug fix would be considered spam by many people because
that can be many emails per week. The commit log is here: https://bitbucket.org/tmidas/midas/commits/branch/develop
If somebody volunteers to consolidate all commits and make a monthly digest to be posted here, I'm all in favor, but I'm not that individual.
Stefan |
|
3205
|
12 Feb 2026 |
Stefan Ritt | Bug Report | omnibus bugs from running DarkLight | Now I had a similar case that the browser froze when showing 24h of data. Tuned out that 80k points are a bit much. I changed the code so that it starts binning when showing 8h or more. This is not a perfect solution. The code should check at which interval data is written, then
automatically start binning when approaching 4000 points or more. That would however require more complicated code, so I leave it as it is right now. Feedback welcome.
Stefan |
|
3173
|
08 Dec 2025 |
Konstantin Olchanski | Bug Report | odbxx memory leak with JSON ODB dump | I was testing odbxx with manalyzer, decided to print an odb value in every event,
and it worked fine in online mode, but bombed out when running from a data file
(JSON ODB dump). The following code has a memory leak. No idea if XML ODB dump
has the same problem.
int memory_leak()
{
midas::odb::set_odb_source(midas::odb::STRING, std::string(run.fRunInfo-
>fBorOdbDump.data(), run.fRunInfo->fBorOdbDump.size()));
while (1) {
int time = midas::odb("/Runinfo/Start time binary");
printf("time %d\n", time);
}
}
K.O. |
|
3176
|
09 Dec 2025 |
Stefan Ritt | Bug Report | odbxx memory leak with JSON ODB dump | Thanks for reporting this. It was caused by a
MJsonNode* node = MJsonNode::Parse(str.c_str());
not followed by a
delete node;
I added that now in odb::odb_from_json_string(). Can you try again?
Stefan |
|
3179
|
09 Dec 2025 |
Konstantin Olchanski | Bug Report | odbxx memory leak with JSON ODB dump | > Thanks for reporting this. It was caused by a
>
> MJsonNode* node = MJsonNode::Parse(str.c_str());
>
> not followed by a
>
> delete node;
>
> I added that now in odb::odb_from_json_string(). Can you try again?
>
> Stefan
Close, but no cigar, node you delete is not the node you got from Parse(), see "node = subnode;".
If I delete the node returned by Parse(), I confirm the memory leak is gone.
BTW, it looks like we are parsing the whole JSON ODB dump (200k+) on every odbxx access. Can you parse it just once?
K.O. |
|
3180
|
10 Dec 2025 |
Stefan Ritt | Bug Report | odbxx memory leak with JSON ODB dump | > BTW, it looks like we are parsing the whole JSON ODB dump (200k+) on every odbxx access. Can you parse it just once?
You are right. I changed the code so that the dump is only parsed once. Please give it a try.
Stefan |
|
3182
|
11 Dec 2025 |
Konstantin Olchanski | Bug Report | odbxx memory leak with JSON ODB dump | > > BTW, it looks like we are parsing the whole JSON ODB dump (200k+) on every odbxx access. Can you parse it just once?
> You are right. I changed the code so that the dump is only parsed once. Please give it a try.
Confirmed fixed, thanks! There are 2 small changes I made in odbxx.h, please pull.
K.O. |
|
3184
|
12 Dec 2025 |
Stefan Ritt | Bug Report | odbxx memory leak with JSON ODB dump | > Confirmed fixed, thanks! There are 2 small changes I made in odbxx.h, please pull.
There was one missing enable_jsroot in manalyzer, please pull yourself.
Stefan |
|
3185
|
12 Dec 2025 |
Konstantin Olchanski | Bug Report | odbxx memory leak with JSON ODB dump | > > Confirmed fixed, thanks! There are 2 small changes I made in odbxx.h, please pull.
> There was one missing enable_jsroot in manalyzer, please pull yourself.
pulled, pushed to rootana, thanks for fixing it!
K.O. |
|
2871
|
09 Oct 2024 |
Lukas Gerritzen | Suggestion | odbedit minor quality of life | I have made two minor quality of life changes to odbedit.
- cd command: Typing cd without arguments now changes the directory to /, similar to the behaviour of the cd command in Linux sending you to the home directory.
- Exit behavior: Upon exiting the program with Ctrl+C, a newline character is printed so that the command line starts on an empty line rather than the last line from odbedit.
Here's the diff:
@@ -1668,7 +1668,10 @@ int command_loop(char *host_name, char *exp_name, char *cmd, char *start_dir)
/* cd */
else if (param[0][0] == 'c' && param[0][1] == 'd') {
- compose_name(pwd, param[1], str);
+ if (strlen(param[1]) == 0)
+ strcpy(str, "/");
+ else
+ compose_name(pwd, param[1], str);
status = db_find_key(hDB, 0, str, &hKey);
@@ -2962,6 +2965,7 @@ void ctrlc_odbedit(INT i)
cm_disconnect_experiment();
+ printf("\n");
exit(EXIT_SUCCESS);
}
Please consider incorporating those changes to odbedit.
Lukas |
|
2872
|
09 Oct 2024 |
Stefan Ritt | Suggestion | odbedit minor quality of life | Ok, accepted, done and pushed.
Stefan
| Lukas Gerritzen wrote: | I have made two minor quality of life changes to odbedit.
- cd command: Typing cd without arguments now changes the directory to /, similar to the behaviour of the cd command in Linux sending you to the home directory.
- Exit behavior: Upon exiting the program with Ctrl+C, a newline character is printed so that the command line starts on an empty line rather than the last line from odbedit.
Here's the diff:
@@ -1668,7 +1668,10 @@ int command_loop(char *host_name, char *exp_name, char *cmd, char *start_dir)
/* cd */
else if (param[0][0] == 'c' && param[0][1] == 'd') {
- compose_name(pwd, param[1], str);
+ if (strlen(param[1]) == 0)
+ strcpy(str, "/");
+ else
+ compose_name(pwd, param[1], str);
status = db_find_key(hDB, 0, str, &hKey);
@@ -2962,6 +2965,7 @@ void ctrlc_odbedit(INT i)
cm_disconnect_experiment();
+ printf("\n");
exit(EXIT_SUCCESS);
}
Please consider incorporating those changes to odbedit.
Lukas |
|
|
2770
|
17 May 2024 |
Konstantin Olchanski | Bug Report | odbedit load into the wrong place | Trying to restore IRIS ODB was a nasty surprise, old save files are in .odb format and odbedit "load xxx.odb"
does an unexpected thing.
mkdir tmp
cd tmp
load odb.xml loads odb.xml into the current directory "tmp"
load odb.json same thing
load odb.odb loads into "/" unexpectedly overwriting everything in my ODB with old data
this makes it impossible for me to restore just /equipment/beamline from old .odb save file (without
overwriting all of my odb with old data).
I look inside db_paste() and it looks like this is intentional, if ODB path names in the odb save file start
with "/" (and they do), instead of loading into the current directory it loads into "/", overwriting existing
data.
The fix would be to ignore the leading "/", always restore into the current directory. This will make odbedit
load consistent between all 3 odb save file formats.
Should I apply this change?
K.O. |
|
2774
|
18 May 2024 |
Stefan Ritt | Bug Report | odbedit load into the wrong place | Taht's strange. I always was under the impression that .odb files are loaded relatively to the current location in
the ODB. The behaviour should not be different for different data formats, so I agree to change the .odb loading to
behave like the .xml and .json save/load.
Stefan |
|
896
|
26 Jul 2013 |
Konstantin Olchanski | Bug Report | odbedit fixed size buffer overrun | odbedit uses a fixed size buffer for ODB data. If an array in ODB is bugger than this size,
db_get_data() correctly returns DB_TRUNCATED and there is no memory overwrite, but the following
code for printing the data does not know about this truncation and proceeds printing memory
values contained after the end of the fixed size data buffer - in the current case, this memory
somehow had the contents of the shell history - this very confused the MIDAS users as they though
that the funny printout was actually in ODB. This is in the print_key() function. If db_get_data()
returns DB_TRUNCATED, it should allocate a buffer of bigger size. This (and the previous) bug found
by the TIGRESS experiment. K.O. |
|
575
|
07 May 2009 |
Konstantin Olchanski | Bug Report | odbedit bad ctrl-C | When using "/bin/bash" shell, if I exit odbedit (and other midas programs) using ctrl-C, the terminal
enters a funny state, "echo" is turned off (I cannot see what I type), "delete" key does not work (echoes
^H instead).
This problem does not happen if I exit using the "exit" command or if I use the "/bin/tcsh" shell.
When this happens, the terminal can be restored to close to normal state using "stty sane", and "stty
erase ^H".
The terminal is set into this funny state by system.c::getchar() and normal settings are never restored
unless the midas program calls getchar(1) at the end. If the program does not finish normally, original
terminal settings are never restored and the terminal is left in a funny state.
It is not clear why the problem does not happen with /bin/tcsh - perhaps they restore sane terminal
settings automatically for us.
K.O. |
|