First time here? Check out the FAQ!
THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

Fix: Unable to access memory when renamed main function and call it in a loop in new main function.

Hi, I renamed the main function of tshark.c as Tb_Main() Like the code in this link: https://github.com/AkibHossainOmi/wir...

I am following this link to have a tshark shared library to get a json string of a pcap file, https://github.com/AkibHossainOmi/Tsh...

specific code section :

int
main(int argc, char* argv[])
{
    // For debug purpose
    // argc = 4;
    // argv[1] = "-Tjson";
    // argv[2] = "-r";
    // argv[3] = "/home/omi/packet.pcap";
    char* result = Tb_Main(argc, argv);
    free(result);
    return exit_status;
}

I change it to,

int
main(int argc, char* argv[])
{
    // For debug purpose
     argc = 4;
     argv[1] = "-Tjson";
     argv[2] = "-r";
     argv[3] = "D:\\Windows\\files\\packet.pcap";
    while (1)
    {
        char* result = Tb_Main(argc, argv);
        free(result);
        printf("Ok\n");
    }
    return exit_status;
}

Now It is giving the exception,

Exception thrown at 0x00007FF9792E6193 (libwsutil.dll) in tshark.exe: 0xC0000005: Access violation reading                             
location 0xFFFFFFFFFFFFFFFF.
Unhandled exception thrown: read access violation.
map->**table** was 0x111011101110111.

Having the exception in different line each time when I am running and debugging it.

Note: This is running in the first time successfully in most cases and getting exception. This tshark source is supposed to return a json string of a pcap file data by the function Tb_Main().

As long as I understood, the pointers are not initiated when I am calling the function more than once.

How can I fix it?

omicron2023's avatar
1
omicron2023
asked 2023-11-26 08:54:52 +0000, updated 2023-11-26 11:37:48 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

I guess you have to ask Akib Hossain Omi for support on his project.

If you have problems compiling using the Wireshark repo https://gitlab.com/wireshark/wireshark and the instructions on Wireshark Developer’s Guide are not clear, you can ask them here or via Discord.

André's avatar
176
André
answered 2023-11-28 22:46:59 +0000
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer