In the v62001/gtm8094pipproc subtest, a recent test enhancement to print the complete DEVOPENFAIL
syslog message resulted in an occasional test failure where the device name was printed as garbage.
For example,
Expected message was
%YDB-E-DEVOPENFAIL, Error opening uname,
%YDB-I-TEXT, PIPE - dup2(pfd_write[0]) failed in child, %SYSTEM-E-UNKNOWN, Unknown system error 0
Actual message was
%YDB-E-DEVOPENFAIL, Error opening .......$...............q5............. .......q......,
%YDB-I-TEXT, PIPE - dup2(pfd_write[0]) failed in child, %SYSTEM-E-UNKNOWN, Unknown system error 0
This turned out to be a longstanding code issue in iopi_open.c.
In the forked off child process in iopi_open(), there are various places where system calls
could error out. In that case, we issue a DEVOPENFAIL error to syslog using dev_name->dollar_io
as the device name. But because an io_rundown() has already been done in the child, the contents
of dev_name are not reliable anymore.
The fix is to copy dev_name->dollar_io and dev_name->len into a local buffer before the io_rundown() call.
Thankfully this is possible with a stack variable since the name is limited to a max of LOGNAME_LEN
(i.e. 255 bytes) in get_log_name().
In the v62001/gtm8094pipproc subtest, a recent test enhancement to print the complete DEVOPENFAIL syslog message resulted in an occasional test failure where the device name was printed as garbage.
For example,
Expected message was %YDB-E-DEVOPENFAIL, Error opening uname, %YDB-I-TEXT, PIPE - dup2(pfd_write[0]) failed in child, %SYSTEM-E-UNKNOWN, Unknown system error 0
Actual message was %YDB-E-DEVOPENFAIL, Error opening .......$...............q5............. .......q......, %YDB-I-TEXT, PIPE - dup2(pfd_write[0]) failed in child, %SYSTEM-E-UNKNOWN, Unknown system error 0
This turned out to be a longstanding code issue in iopi_open.c.
In the forked off child process in iopi_open(), there are various places where system calls could error out. In that case, we issue a DEVOPENFAIL error to syslog using dev_name->dollar_io as the device name. But because an io_rundown() has already been done in the child, the contents of dev_name are not reliable anymore.
The fix is to copy dev_name->dollar_io and dev_name->len into a local buffer before the io_rundown() call. Thankfully this is possible with a stack variable since the name is limited to a max of LOGNAME_LEN (i.e. 255 bytes) in get_log_name().