#3766·glances

Export preparation mutates live plugin statistics and contaminates shared snapshots

Author: HassanRadyCreated Sep 28, 2026Updated Sep 28, 2026

Check the bug

I searched the repository’s existing issues, pull requests, and discussions and did not find an existing report or merged fix for this exact mutation.

Describe the bug

Export preparation mutates the live statistics objects owned by plugins.

GlancesStats.getAllExports() and GlancesStats.getAllExportsAsDict() return the objects provided by each plugin’s get_export() method without copying them. Exporters subsequently modify those objects in place while merging limit fields and removing <plugin>_disable fields.

Because APIs, UIs, and other exporters may read the same objects, clients can observe exporter-only limit fields, missing disable fields, or changes made by another concurrent exporter.

Affected paths include:

  • glances/stats.py
  • glances/exports/export.py
  • glances/exports/glances_timescaledb/__init__.py
  • glances/exports/glances_duckdb/__init__.py
  • glances/exports/glances_clickhouse/__init__.py

To Reproduce

Steps to reproduce the behavior:

  1. Use a plugin whose get_export() method returns its live statistics dictionary:

    python
    live_stats = {"total": 12, "user": 7}
    limits = {"cpu_warning": 70, "cpu_disable": False}
  2. Retrieve the plugin through GlancesStats.getAllExportsAsDict().

  3. Run the standard GlancesExport.update() preparation logic.

  4. Inspect live_stats after export preparation.

  5. Observe that the original dictionary has changed:

    python
    {
        "total": 12,
        "user": 7,
        "cpu_warning": 70,
    }

The same problem occurs for list-based plugin statistics because each row is updated in place.

A second call to either export getter can also observe changes made through the result of the first call, demonstrating that exporters do not receive isolated snapshots.

Expected behavior

Export preparation should operate on an independent snapshot. It must not modify plugin-owned live statistics or data returned to APIs, UIs, or other exporters.

Each call to getAllExports() or getAllExportsAsDict() should return a fully detached copy, including dictionaries nested inside list-based statistics.

Screenshots

Not applicable.

Environement (please complete the following information)

  • Operating System: Linux/WSL; the issue is platform-independent
  • Glances & psutil versions: Glances develop at b3f1cf00 (4.5.8.dev1)
  • How do you install Glances: Source checkout
  • Glances test: Reproduced with a focused unit test using both dictionary-based and list-based plugin statistics

Additional context Fix in PR #3767