Rate This Document
Findability
Accuracy
Completeness
Readability

Incremental Scans

Each time a scan is complete, the system generates a scan report and saves the full report data to the historical reports. If -eh is set to true for another scan, the tool compares the current scan result with the previous historical report. If the current result is the same as the previous one (except for new line numbers), the report is filtered out, but the historical report still retains the complete information.

  • A maximum of 100 historical reports can be saved. If the number of historical reports exceeds 100, the earliest reports are automatically deleted.
  • If the code content remains unchanged but the line number changes by more than 100 lines, duplicate races cannot be identified. As a result, the filtering fails.
  1. Compile the source file to generate an executable binary file.
    1
    gcc test_barrier.c -o test_barrier -g -lpthread
    

    Content of the test_barrier.c file:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    #include <unistd.h>
    #include <pthread.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    
    volatile int *x,*y,*r1,*r2;
    volatile int flag;
    
    
    void thread0(void *arg)
    {
        while(flag == 0);
        *y = 1;
        *x = 1;
    }
    
    void thread1(void *arg)
    {
        while(flag == 0);
        *r2 = *x;
        *r1 = *y;
    }
    
    int main()
    {
        int n = 0;
        int count = 0;
        while(n < 100) {
            pthread_t t1, t2;
            x = (int *)malloc(sizeof(int));
            y = (int *)malloc(sizeof(int));
            r1 = (int *)malloc(sizeof(int));
            r2 = (int *)malloc(sizeof(int));
            *x = *y = *r1 = *r2 = flag = 0;
    
            pthread_create(&t1, NULL, (void *)thread0, NULL);
            pthread_create(&t2, NULL, (void *)thread1, NULL);
    
            usleep(10);
            flag = 1;
    
            pthread_join(t1, NULL);
            pthread_join(t2, NULL);
    
            if (*r1 == 0 && *r2 == 1)
            {
                printf("error %d\n", n);
                count++;
            }
    
            free((void *)x);
            free((void *)y);
            free((void *)r1);
            free((void *)r2);
            n++;
        }
        printf("Run %d times, error %d times.\n", n, count);
        return 0;
    }
    
  2. Perform dynamic memory consistency check.
    devkit advisor dr-check -f /home/advisor/test_barrier

    /home/advisor/test_barrier: ELF file path. Replace the example path with the actual one.

    The following information in bold indicates that six lines of code need to be modified.

    Executing dynamic memory consistency check task, please wait...
    The pid of the memtracer process is 773285
    Scanned time: 2025/11/17 08:02:55
    
    Configuration:
        ELF filepath: /home/advisor/test_barrier
        Scan source code path: None
        Generate report path: /home/DevKit_Software
        Generate report type: all
        Task Timeout Interval: The timeout period is not set.
        Log level: info
    
    Summary:
    There are 6 recommended code lines to modify.
    
    For the detailed information on multi-thread races, please check:
        /home/DevKit_Software/dr-check_test_barrier_20251117080255_2458.json
        /home/DevKit_Software/dr-check_test_barrier_20251117080255_2458.html
        /home/DevKit_Software/dr-check_test_barrier_20251117080255_2458.csv
  3. View the scan report. It is found that there are three pairs of data race issues, one file to be modified, and six lines of code to be modified.
    Figure 1 Scan report
  4. Perform dynamic memory consistency check again. If -eh is set to true, historical report filtering is enabled. Identified data race issues will be automatically filtered out.
    devkit advisor dr-check -f /home/advisor/test_barrier -eh true

    In the command output, the information in bold indicates that no lines of code need to be modified, but the historical reports still retain complete data, including the filtered content.

    Executing dynamic memory consistency check task, please wait...
    The pid of the memtracer process is 796538
    Scanned time: 2025/11/17 09:05:48
    
    Configuration:
        ELF filepath: /home/advisor/test_barrier
        Scan source code path: None
        Generate report path: /home/DevKit_Software
        Generate report type: all
        Task Timeout Interval: The timeout period is not set.
        Log level: info
    
    Summary:
    There are 0 recommended code lines to modify.
    
    For the detailed information on multi-thread races, please check:
        /home/DevKit_Software/dr-check_test_barrier_20251117090548_e08d.json
        /home/DevKit_Software/dr-check_test_barrier_20251117090548_e08d.html
        /home/DevKit_Software/dr-check_test_barrier_20251117090548_e08d.csv

    A JSON report can be regarded as another form of an HTML report. If historical result filtering is enabled, the generated JSON report contains the is_new field (in both the current report and historical report), which is used to indicate whether the data is added (true) or filtered (false).

  5. View a historical report.

    Historical scan reports are stored in the advisor/dr_check_reports/{elf_name}_{md5sum(elf_path)}/Timestamp folder and contain the following content:

    • source: stores source files.
    • dr_check_mp_Timestamp_Random_number.json: Multi-process report, which is generated when multi-process check is enabled.
    • dr_check_{elf_name}_Timestamp_Random_number.json: Multi-thread report.
    • mp_Timestamp.memtracer_mp_report: Multi-process file in plain text format. It is generated when enabling multi-process check and is used to parse historical reports (through the -dm option).
    • mp_Timestamp.memtracer_mp_report.json: Multi-process file in JSON format, which is generated when enabling multi-process check.
    • {elf_name}.memtracer_report: parent process/thread report, which is used to parse historical reports (through the -d option). If multi-process check is enabled, a thread report is generated, but multiple historical reports are saved.
    • {elf_name}_PID.memtracer_report: sub process/thread report, which is used to parse historical reports (through the -d option). This file is generated when enabling multi-process check.
  6. View details about a historical report.
    1
    vi dr-check_test_barrier_20251117090548_e08d.json
    

    It can be seen that the historical report retains complete data. There are three pairs of data race issues, six lines of code to be modified, and one file to be modified.

    Figure 2 JSON report content (1)

    The is_new field indicates that the data is filtered.

    Figure 3 JSON report content (2)