Repository: valkey-io/valkey
File: src/debug.c (C)

Code before:
            "    Run a fuzz tester against the stringmatchlen() function.",
            "STRUCTSIZE",
            "    Return the size of different core C structures.",
            "LISTPACK <key>",
            "    Show low level info about the listpack encoding of <key>.",
            "QUICKLIST <key> [<0|1>]",
            "    Show low level info about the quicklist encoding of <key>.",
            "    The optional argument (0 by default) sets the level of detail",
            "CLIENT-EVICTION",
            "    Show low level client eviction pools info (maxmemory-clients).",
            "PAUSE-CRON <0|1>",
            "    Stop periodic cron job processing.",
            "REPLYBUFFER PEAK-RESET-TIME <NEVER||RESET|time>",
            "    Sets the time (in milliseconds) to wait between client reply buffer peak resets.",
            "    In case NEVER is provided the last observed peak will never be reset",
            "    In case RESET is provided the peak reset time will be restored to the default value",
            "REPLYBUFFER RESIZING <0|1>",
            "    Enable or disable the reply buffer resize cron job",
            "PAUSE-AFTER-FORK <0|1>",
            "    Stop the server's main process after fork.",
            "DELAY-RDB-CLIENT-FREE-SECOND <seconds>",
            "    Grace period in seconds for replica main channel to establish psync.",
            "DICT-RESIZING <0|1>",
            "    Enable or disable the main dict and expire dict resizing.",
            "CLIENT-ENFORCE-REPLY-LIST <0|1>",
            "When set to 1, it enforces the use of the client reply list directly",
            "    and avoids using the client's static buffer.",
            NULL};
        addExtendedReplyHelp(c, help, clusterDebugCommandExtendedHelp());
    } else if (!strcasecmp(c->argv[1]->ptr, "segfault")) {
        /* Compiler gives warnings about writing to a random address
         * e.g "*((char*)-1) = 'x';". As a workaround, we map a read-only area
         * and try to write there to trigger segmentation fault. */
        char *p = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
        *p = 'x';
    } else if (!strcasecmp(c->argv[1]->ptr, "panic")) {
        serverPanic("DEBUG PANIC called at Unix time %lld", (long long)time(NULL));
    } else if (!strcasecmp(c->argv[1]->ptr, "restart") || !strcasecmp(c->argv[1]->ptr, "crash-and-recover")) {
        long long delay = 0;
        if (c->argc >= 3) {
            if (getLongLongFromObjectOrReply(c, c->argv[2], &delay, NULL) != C_OK) return;
            if (delay < 0) delay = 0;
        }
        int flags = !strcasecmp(c->argv[1]->ptr, "restart")
                        ? (RESTART_SERVER_GRACEFULLY | RESTART_SERVER_CONFIG_REWRITE)
                        : RESTART_SERVER_NONE;
        restartServer(c, flags, delay);
        addReplyError(c, "failed to restart the server. Check server logs.");
    } else if (!strcasecmp(c->argv[1]->ptr, "oom")) {
        void *ptr = zmalloc(SIZE_MAX / 2); /* Should trigger an out of memory. */
        zfree(ptr);

Review comment (suggestion):
```suggestion
            "    When set to 1, it enforces the use of the client reply list directly",
```

Code after:
            "    Run a fuzz tester against the stringmatchlen() function.",
            "STRUCTSIZE",
            "    Return the size of different core C structures.",
            "LISTPACK <key>",
            "    Show low level info about the listpack encoding of <key>.",
            "QUICKLIST <key> [<0|1>]",
            "    Show low level info about the quicklist encoding of <key>.",
            "    The optional argument (0 by default) sets the level of detail",
            "CLIENT-EVICTION",
            "    Show low level client eviction pools info (maxmemory-clients).",
            "PAUSE-CRON <0|1>",
            "    Stop periodic cron job processing.",
            "REPLYBUFFER PEAK-RESET-TIME <NEVER||RESET|time>",
            "    Sets the time (in milliseconds) to wait between client reply buffer peak resets.",
            "    In case NEVER is provided the last observed peak will never be reset",
            "    In case RESET is provided the peak reset time will be restored to the default value",
            "REPLYBUFFER RESIZING <0|1>",
            "    Enable or disable the reply buffer resize cron job",
            "PAUSE-AFTER-FORK <0|1>",
            "    Stop the server's main process after fork.",
            "DELAY-RDB-CLIENT-FREE-SECOND <seconds>",
            "    Grace period in seconds for replica main channel to establish psync.",
            "DICT-RESIZING <0|1>",
            "    Enable or disable the main dict and expire dict resizing.",
            "CLIENT-ENFORCE-REPLY-LIST <0|1>",
            "    When set to 1, it enforces the use of the client reply list directly",
            "    and avoids using the client's static buffer.",
            NULL};
        addExtendedReplyHelp(c, help, clusterDebugCommandExtendedHelp());
    } else if (!strcasecmp(c->argv[1]->ptr, "segfault")) {
        /* Compiler gives warnings about writing to a random address
         * e.g "*((char*)-1) = 'x';". As a workaround, we map a read-only area
         * and try to write there to trigger segmentation fault. */
        char *p = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
        *p = 'x';
    } else if (!strcasecmp(c->argv[1]->ptr, "panic")) {
        serverPanic("DEBUG PANIC called at Unix time %lld", (long long)time(NULL));
    } else if (!strcasecmp(c->argv[1]->ptr, "restart") || !strcasecmp(c->argv[1]->ptr, "crash-and-recover")) {
        long long delay = 0;
        if (c->argc >= 3) {
            if (getLongLongFromObjectOrReply(c, c->argv[2], &delay, NULL) != C_OK) return;
            if (delay < 0) delay = 0;
        }
        int flags = !strcasecmp(c->argv[1]->ptr, "restart")
                        ? (RESTART_SERVER_GRACEFULLY | RESTART_SERVER_CONFIG_REWRITE)
                        : RESTART_SERVER_NONE;
        restartServer(c, flags, delay);
        addReplyError(c, "failed to restart the server. Check server logs.");
    } else if (!strcasecmp(c->argv[1]->ptr, "oom")) {
        void *ptr = zmalloc(SIZE_MAX / 2); /* Should trigger an out of memory. */
        zfree(ptr);