Skip to content

chaosblade 1.7.4 not work for c++ application function Delay #1253

Open

Description

@perrynzhou

Issue Description

Type: bug report , feature request or question

Describe what happened (or what feature you want)

  • when i inject delay for c++ method ,it not work.my command such as
./blade  prepare cplus -i 127.0.0.1  -p 9703
./blade create cplus delay \
  --fileLocateAndName /nvm_pool/data/cplus/example_server \
  --breakLine example_server.cc:24 \
  --delayDuration 2000 \
  --processName example_server \
  --forkMode parent
  • example_server.cc
#include <iostream>
#include <unistd.h>
#include <sys/time.h>
#include <cstring>
#include <ctime>
#include <fcntl.h>
#include <string.h>
void time_to_str(const char *str, int fd)
{
    std::time_t now = std::time(nullptr);

    std::tm *local_time = std::localtime(&now);
    char time_str[128] = {'\0'};
    snprintf((char *)&time_str, 128, "%s", str);
    size_t len = strlen((char *)&time_str);
    std::strftime((char *)&time_str + len, sizeof(time_str) - len, "%Y-%m-%d %H:%M:%S\n", local_time);

    write(fd, &time_str, 128);
    // std::cout << str << time_str << std::endl;
}
void handleRequest(int *requestId, int fd)
{
    // 模拟一些处理时间
    usleep(100000); // 0.1秒
    char done_str[128] = {'\0'};
    sprintf((char *)&done_str, "done  request-%ld", *requestId);
    write(fd, &done_str, 128);
    // std::cout << done_str << std::endl;
}

int main()
{

    int fd = open("/tmp/1.log", O_CREAT | O_TRUNC | O_RDWR | O_SYNC | O_APPEND);
    int requestCount = 0;
    while (true)
    {
        requestCount++;
        time_to_str("***handleRequest开始处理时间:", fd);
        handleRequest(&requestCount, fd);
        time_to_str("***handleRequest结束处理时间:", fd);
    }
    return 0;
}

Describe what you expected to happen

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

Anything else we need to know?

Activity

  1. changed the title [-]chaosblade 1.8.0 not support c++ application function Delay[/-] [+]chaosblade 1.7.4 not work for c++ application function Delay[/+] on Nov 10, 2025
  2. self-assigned this
    on Nov 11, 2025
  3. added
    chaosblade-exec-cplus
    on Nov 11, 2025
  4. added theissue type on Nov 11, 2025
  5. xcaspar commented on Nov 11, 2025

    @xcaspar
    Member

    This problem exists, and we are still working on refactoring the cplus fault injection project.

  6. oss-sentinel-ai commented on Jun 4, 2026

    @oss-sentinel-ai
    Contributor

    Issue Evaluation

    Category: type/bug | Status: Acknowledged | Severity: Medium

    The issue reports that C++ function delay injection does not work with ChaosBlade 1.7.4. Maintainer @xcaspar has acknowledged the problem and confirmed that the chaosblade-exec-cplus project is being refactored.

    Status: Known issue. The C++ fault injection module is undergoing refactoring. Users should watch for updates in the chaosblade-exec-cplus repository.

    Recommendation: Track the refactoring progress in chaosblade-exec-cplus. Once the refactored version is released, this issue should be retested.


    Automated evaluation by oss-taishan-ai - ChaosBlade Community Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

chaosblade-exec-cplus

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions