Skip to content

Deadlock in fern logging #150

@kpraneet

Description

@kpraneet

Hello @daboross! I have identified a deadlock issue in fern that occurs intermittently when disk space is exhausted during logging operations.

The deadlock scenario:

  1. During active logging with fern, the stream lock is acquired
  2. The disk becomes full mid-write
  3. The code attempts to use backup logging (to stderr) while still holding the stream lock
  4. This creates a circular dependency in multi-threaded scenarios

To reproduce:

  1. I modified the cmd-program.rs example to include multi-threading (attached)
  2. Used the disk-filling utility from https://www.cylog.org/utilities/filldisk.jsp
  3. Run the modified example while filling the disk

Proposed solution:
Release the stream lock before attempting error handling to prevent the circular dependency.
Do you have any thoughts, suggestions or alternatives to this proposed solution?

I've attached both the modified example and a thread dump showing the deadlock.

Let me know if you need any additional information or clarification. Happy to provide more details or discuss alternative solutions.

Thanks!

main.txt

full_disk.dmp

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions