How to debug getdents syscall hanging inside docker container

I ran some unit tests that created a lot of files in /tmp inside a docker container, which was serving as a development environment. Now the following commands hang:

ls /tmp
rm -rf /tmp

I was able to get somewhat unblocked by running mv /tmp /tmpold to clear the way to create a new empty temp directory, but the same hanging behavior is still occuring for /tmpold. Running strace shows that both processes are getting hung on a getdents system call. I also reproduced this with a simple c program that includes the following snippet:

  fd = open(argc > 1 ? argv[1] : ".", O_RDONLY | O_DIRECTORY);
  if (fd == -1)

  for ( ; ; ) {
    nread = syscall(SYS_getdents, fd, buf, BUF_SIZE);
    if (nread == -1)

How can I debug this further, or is there another approach to deleting or listing this directory that may have a chance of shedding light on the issue, or at least what the files are in the directory?

Source: StackOverflow