bloomberg / bde

Basic Development Environment - a set of foundational C++ libraries used at Bloomberg.
Apache License 2.0
1.67k stars 316 forks source link

Test failure in `balb_pipecontrolchannel` #300

Closed dgoffredo closed 1 month ago

dgoffredo commented 1 month ago

When I run test case 8 for balb_pipecontrolchannel on my Ubuntu 22.04 system with g++ 11.4.0, the parent process hangs trying to create a named pipe. This is because it detects that the pipe exists and has no readers, and so calls BDE's remove. However, recently BDE's remove was modified to open the file in order to handle symbolic links. Opening the named pipe without someone on the other end causes the hang.

https://github.com/bloomberg/bde/blame/e862d6bceef0857085fb000f5c8b204c96aeb63b/groups/bdl/bdls/bdls_filesystemutil.cpp#L2545-L2548

https://github.com/bloomberg/bde/blob/e862d6bceef0857085fb000f5c8b204c96aeb63b/groups/bal/balb/balb_pipecontrolchannel.cpp#L460

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007d100ef146b6 in __libc_openat64 (fd=4, file=0x7ffe8eabe220 "ctrl.pcctest.8.315137", oflag=131072) at ../sysdeps/unix/sysv/linux/openat64.c:39
39  ../sysdeps/unix/sysv/linux/openat64.c: No such file or directory.
(gdb) where
#0  0x00007d100ef146b6 in __libc_openat64 (fd=4, 
    file=0x7ffe8eabe220 "ctrl.pcctest.8.315137", oflag=131072)
    at ../sysdeps/unix/sysv/linux/openat64.c:39
#1  0x0000609980a06925 in BloombergLP::bdls::FilesystemUtil::remove (
    path=0x609981101530 "/home/david/src/bde/ctrl.pcctest.8.315137", 
    recursiveFlag=false)
    at /home/david/src/bde/groups/bdl/bdls/bdls_filesystemutil.cpp:2545
#2  0x0000609980a01dfc in BloombergLP::balb::PipeControlChannel::createNamedPipe
    (this=0x7ffe8eabfa70, 
    pipeName=0x609981101530 "/home/david/src/bde/ctrl.pcctest.8.315137")
    at /home/david/src/bde/groups/bal/balb/balb_pipecontrolchannel.cpp:460
#3  0x0000609980a02485 in BloombergLP::balb::PipeControlChannel::start (
    this=0x7ffe8eabfa70, 
    pipeName=0x609981101530 "/home/david/src/bde/ctrl.pcctest.8.315137", 
    attributes=...)
    at /home/david/src/bde/groups/bal/balb/balb_pipecontrolchannel.cpp:607
#4  0x00006099809f7bfe in BloombergLP::balb::PipeControlChannel::start<bsl::basic_string<char, std::char_traits<char>, bsl::allocator<char> > > (
    this=0x7ffe8eabfa70, pipeName=..., threadAttributes=...)
    at /home/david/src/bde/groups/bal/balb/balb_pipecontrolchannel.h:459
#5  0x00006099809f6cd5 in BloombergLP::balb::PipeControlChannel::start<BloombergLP::bslstl::StringRefImp<char> > (this=0x7ffe8eabfa70, pipeName=...)
    at /home/david/src/bde/groups/bal/balb/balb_pipecontrolchannel.h:451
#6  0x00006099809ec653 in (anonymous namespace)::ControlServer::start (
    this=0x7ffe8eabfa70, pipeName=...)
    at /home/david/src/bde/groups/bal/balb/balb_pipecontrolchannel.t.cpp:257
#7  0x00006099809f007c in main (argc=7, argv=0x7ffe8eac0118)
    at /home/david/src/bde/groups/bal/balb/balb_pipecontrolchannel.t.cpp:1441
(gdb) up
#1  0x0000609980a06925 in BloombergLP::bdls::FilesystemUtil::remove (
    path=0x609981101530 "/home/david/src/bde/ctrl.pcctest.8.315137", 
    recursiveFlag=false)
    at /home/david/src/bde/groups/bdl/bdls/bdls_filesystemutil.cpp:2545
2545        FileDescriptor leafFD = ::openat(parentFD,
(gdb) print path
$1 = 0x609981101530 "/home/david/src/bde/ctrl.pcctest.8.315137"
(gdb) 
mversche commented 1 month ago

Thanks. This appears to be a bug. Our aim is to address it before friday, otherwise we will back out the filesystem change while we fix it.

dgoffredo commented 1 month ago

Fixed in https://github.com/bloomberg/bde/commit/c5f63b61da6e245df90cee8af8e7fba54b57e3cc.