N
N
Nerd0_02019-05-03 14:35:37
linux
Nerd0_0, 2019-05-03 14:35:37

How to deal with SIGSEGV in MariaDB?

There is such a program:

#include <iostream>
#include "include/mysql.h"
#include <Poco/Data/Session.h>
#include <Poco/Data/SQLite/Connector.h>
#include "include/Server.h"
#include "src/DBConnector.cpp"

void show_error(MYSQL *mysql)
{
    printf("Error(%d) [%s] \"%s\"", mysql_errno(mysql),
           mysql_sqlstate(mysql),
           mysql_error(mysql));
    mysql_close(mysql);
    exit(-1);
}

int main(int i,char* args[]){
    MYSQL *mysql;
    const char *query;

    mysql_debug("d:t:O");

    mysql= mysql_init(NULL);

    if (!mysql_real_connect(mysql, "localhost", "stats", "q1w2e3r4",
                            "example_db", 0, "/var/run/mysqld/mysqld.sock", 0))
        show_error(mysql);

    mysql_close(mysql);

    return 0;
}

When I try to run it, an error occurs:
Program received signal SIGSEGV, Segmentation fault.
__strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:173
173	../sysdeps/x86_64/multiarch/../strcmp.S: Нет такого файла или каталога.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.

However, this code was copied from an example that works without crashes. What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2019-05-03
@MechanID

The problem is that you are not reading the error.
173 ../sysdeps/x86_64/multiarch/../strcmp.S: No such file or directory.

V
ValdikSS, 2019-05-06
@ValdikSS

Run the program under a debugger and see exactly where the crash occurs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question