WhiteBox-Systems / whitebox

A tool for showing software developers how their (C/C++) code behaves as they write it. (README and public issues)
https://whitebox.systems
17 stars 0 forks source link

Crash related to struct type visualization #16

Open fafok29 opened 2 years ago

fafok29 commented 2 years ago

What happened?

Actual behavior:

If struct type visualization is enabled Whitebox will crash if you have the invalid syntax in your struct. Accidentally stumbled on it when I made a typo.

Expected behavior: It shouldn't crash

https://user-images.githubusercontent.com/23638076/187097741-74a49bf6-1812-4be2-ac31-913803a56a92.mp4

System/app details

WhiteBox version - 0.96.0 WhiteBox commit - 3424f59f3846a7911ec7a085051b3335c7980459 Assert level - 1 Debug info - false Kernel - Linux 5.15.0-46-generic OS - Ubuntu 22.04.1 LTS Architecture - x86-64 CPU name - Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz CPU count - 8 CPU MHz - RAM - 16G

How to reproduce the error

Steps to reproduce:

  1. start Whitebox
  2. connect from vim
  3. open code example
  4. enable struct type visualization
  5. try to add or delete comma(',') inside of test_t struct near int a; (watch video)
  6. Whitebox crashed ...

Does the error happen consistently with the above steps? Kinda 100%, I don't know the exact steps to reproduce, but doing something similar to what I did in video should be enough (though it might take a few tries)

Minimal reproducible code example:

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct {
    int a;,,
        int  b;
} test_t;

int foo()
{

    int a = 0;

    return a;
}

char *malloc_test(int arg)
{
    char *ptr = malloc(arg * sizeof(char));

    for (int i = 0; i < arg - 1; i++) {
        ptr[i] = 'a';
    }
    ptr[arg] = '\0';

    return ptr;
}

int main()
{
    return 0;
}

Crash/log attachments & additional info

[ ] whitebox-log.txt file - not generated - idk why

P.S. I suspect you use arena or something like that and preallocate/map a lot of memory, because of that gdb generates big >16G core files, because it dumps a full memory map, but if you won't be able to reproduce I will look for a way to reduce core file size and will attach it.

fafok29 commented 2 years ago

Also, in the video pay attention to when I save file in vim, I suspect it might be related.

azmr commented 2 years ago

Thanks for the bug report @fafok29

I'm not sure it's currently made clear enough, but everything in the Features menu is experimental/mid-development and should be treated as unstable.

That said, I've been able to reproduce this with your code, so thank you 😄 This is on the backlog for now as we have some other higher-priority tasks, but this will be helpful when we get back round to it.