ESP8266 throws Exception (0) error[SOLVED]

Hi! I'm trying to connect my db to a web app from the SPIFFS memory. I'm using this SqlLite library. In this process I'm calling the LogIn function listed down in the web page, but whenever I press the button in the web app I'm getting the Exception (0) error. Does anyone know what I am doing wrong here? A little guidance would be tremendous.

LogIn() function

void LogIn() {
//getting credentials from page
     String UserCNP = server.arg("Username");
    String UserPassword = server.arg("Password");
//storing instruction in buffer
    sprintf(buffer, "SELECT CNP, FirstName, LastName from Users WHERE (CNP='%s') AND (Password='%s');", UserCNP.c_str(), UserPassword.c_str());
//executing sql querry
    rc = db_exec(db1, buffer);
    if (rc != SQLITE_OK)
    {
        sqlite3_close(db1);
        return;
    }
//sending sql querry to the client
   server.send(200, "application/json", response);
}

Error message

Exception (0):
epc1=0xc1127108 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3fff56f0 end: 3fff5dc0 offset: 01a0

>>>stack>>>
3fff5890:  402016d7 3ffe8c20 000002a0 40205cb0  
3fff58a0:  40202574 3fff8254 000002a0 4023a407  
3fff58b0:  00000001 3fff8254 3fffaab4 4023a5e3  
3fff58c0:  00000002 3fff59d0 00025e2c 40239afb  
3fff58d0:  3fffa894 00000200 3fff7dd4 00000200  
3fff58e0:  00000001 00000000 00000200 00000200  
3fff58f0:  3fff7dd4 00000002 3fffaab4 402349c0  
3fff5900:  00000002 00000002 3ffe8c20 402144f9  
3fff5910:  3fff5950 00000002 3fff7ee4 00000000  
3fff5920:  00000000 00000148 00000148 3fff7d0c  
3fff5930:  3fff94a0 00000000 3fff942c 40234cc4  
3fff5940:  757e3c9e 0000000a 00000001 40213e3b  
3fff5950:  3fffaab4 0000000a 3fff9034 3fff903f  
3fff5960:  00000002 00000000 0000000a 00000000  
3fff5970:  3fff903e 00000000 40201779 3fff942c  
3fff5980:  3fff8c68 00000000 3fff942c 40214200  
3fff5990:  3fff903f 00000000 00000000 40216d1a  
3fff59a0:  00000000 3fff59d0 00000009 4020adfc  
3fff59b0:  00000000 3fff5a00 00000004 00000004  
3fff59c0:  00000001 00000001 96ee5e30 40202574  
3fff59d0:  96ee5e30 00000004 78c00000 42125bb9  
3fff59e0:  3fff8c68 3fff8f34 00000000 00000000  
3fff59f0:  3fff8c68 3fff93ac 00000000 40226a86  
3fff5a00:  00000000 00000000 00000000 00000000  
3fff5a10:  00000001 00000000 00000000 00000000  
3fff5a20:  00000000 00000000 00000000 00000000  
3fff5a30:  00000000 00000000 00000000 00000000  
3fff5a40:  00000000 0000ffff 00000000 00000001  
3fff5a50:  00000002 00000000 3f010003 00000000  
3fff5a60:  3fff953c 3fff79dc 3fff8f0c 3fff7cdc  
3fff5a70:  00000000 00000006 3fff8c2c 00000000  
3fff5a80:  3f000002 00000000 00000006 00000004  
3fff5a90:  00000007 00000001 3fff93da 40245800  
3fff5aa0:  3fff93a4 401043ee 3fff6fdc 402438d0  
3fff5ab0:  96ee5e30 00000004 3fff5b40 4023f921  
3fff5ac0:  3ffeed35 3fff7974 3fff5af0 3fff62f5  
3fff5ad0:  40101be9 3fff27c0 3fff93a4 00000000  
3fff5ae0:  3fff953c 3fff79dc 3fff79dc 402282ce  
3fff5af0:  00000003 00000000 00000000 3fff93e8  
3fff5b00:  3ffe8304 0455c6e8 00000002 00000100  
3fff5b10:  7fffffff 3ffe925d 3ffef5ec 00000001  
3fff5b20:  00000001 00004a88 3fff93a4 3ffe925d  
3fff5b30:  3fff4711 00000001 00000000 00000000  
3fff5b40:  00000000 00000000 3fff4712 00000000  
3fff5b50:  00000000 00000000 00000000 00000000  
3fff5b60:  00000000 00000000 0000000f 00000000  
3fff5b70:  40237062 00000001 00000001 3fff4d8c  
3fff5b80:  3fff5c10 00000000 00000000 4010053d  
3fff5b90:  00000010 00000010 00000000 ffffffff  
3fff5ba0:  3fff79dc 3fff46b8 3fff5c10 4022d00a  
3fff5bb0:  3fff5c14 00000003 3fff5c50 4023db0b  
3fff5bc0:  00000001 00000000 3fff5c50 402381dc  
3fff5bd0:  00000033 3fff45cc 3fff5e00 3fff46b8  
3fff5be0:  00000053 00000000 3fff79dc 4022d190  
3fff5bf0:  3fff5c14 7fffffff 3fff5c5c 00000000  
3fff5c00:  00000000 00000000 3fff79dc 402283ff  
3fff5c10:  3fff953c 3fff4712 3fff5c9c 402381dc  
3fff5c20:  00000003 00000000 3fff45c8 40235854  
3fff5c30:  0000000c 3ffe9420 0000001c 4023eda8  
3fff5c40:  3ffe9270 00000008 3fff5e00 0455d170  
3fff5c50:  3fff46b8 3fff45c8 3fff5e00 40235a27  
3fff5c60:  3fff79dc 3fff45cc 3fff8bec 3fff7974  
3fff5c70:  6000001c ff000000 3fff5e00 402381dc  
3fff5c80:  3fff46b8 3fff45cc 3fff487c 40235b78  
3fff5c90:  00000000 00000000 00000000 3fff7974  
3fff5ca0:  0000000f 00000003 3fff8bec 0000000f  
3fff5cb0:  0000000b 00000724 00000724 4010020c  
3fff5cc0:  00000001 00000001 3fff781c 4023e54e  
3fff5cd0:  00000000 00000000 3fff781c 402381d2  
3fff5ce0:  3fff781c 3fff4610 3fff781c 4023820e  
3fff5cf0:  00000000 00000000 00000000 4023dcb4  
3fff5d00:  3fff781c 3fff4610 3fff45cc 40238295  
3fff5d10:  3fffa354 0000000f 00000006 00000000  
3fff5d20:  00000000 3fff5d70 3fff45d0 40236d2c  
3fff5d30:  3fff4610 00000001 3fff4da0 3fff45f4  
3fff5d40:  00000001 00000000 40237664 0000000f  
3fff5d50:  00000000 3fffa5fc 3fff45cc 3fff4d98  
3fff5d60:  00000001 3fff45f4 3fff45cc 4023848c  
3fff5d70:  40107658 00000000 00001388 00000000  
3fff5d80:  00000000 3fffa5fc 3fff795c feefeffe  
3fff5d90:  3fffdad0 00000000 3fff4d90 40235fb4  
3fff5da0:  3fffdad0 00000000 3fff4d90 4023c440  
3fff5db0:  feefeffe feefeffe 3fff4da0 4010071c  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,7)


 ets Jan  8 2013,rst cause:4, boot mode:(1,7)

wdt reset

P.S.: If I use the instructions from the LogIn function in setup function it works perfectly.

How large is the buffer?

450, it's delcared like this: char buffer[450];
Isn't that enough?

That should be enough unless you have really long usernames or passwords.

Can you share the rest of the sketch?

You might want to have a look at this post.

This is the code.Sorry for all the mess here, I've tried to comment some things to make it easier to understand.

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
#include <vfs.h>
#include <SPI.h>
#include <FS.h>
extern "C" {
#include "user_interface.h"
}

//Creating table
const char* createTableUser = "CREATE TABLE Users (CNP INTEGER PRIMARY KEY, FirstName VARCHAR2(16), LastName VARCHAR2(16), Password VARCHAR2(12) NOT NULL,PhoneNumber VARCHAR2(10), Email VARCHAR2(16), TagNumber VARCHAR2(16), Credit NUMBER(4,2) NOT NULL, IsAdmin NUMBER(1) NOT NULL, IsActive NUMBER(1) NOT NULL);";
//Inserting users
const char* insertUser = "INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (19712073264,'Ion', 'Vasilescu', 'abc', 4.85, 1, 1);";
const char* insertUser2 = "INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (29210144293, 'Maria', 'Ionescu', '346456',2.20, 0, 1 );";
//showing all users in db
const char* sqlAllUsers = "SELECT * FROM Users;";


int rc;
sqlite3* db1;
char buffer[450];
String response = "{";
//CONNECT TO LOCAL NETWORK
ESP8266WebServer server;
char* ssid = "ssid";
char* password = "password";
//open file in SPIFFS memory
void GetIndexPage()
{
    File file = SPIFFS.open("/index.html", "r");
    server.streamFile(file, "text/html");
}

void LogIn();

const char* data = "Callback function called";
static int callback(void* data, int argc, char** argv, char** azColName)
{
    int i;
    Serial.printf("%s: \r\n", (const char*)data);
    bool functionCalled = true;
    for (i = 0; i < argc; i++)
    {
        Serial.printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");

        if (argv[i] != NULL)
        {
            //I want to send the response in a json format so that's why all this
            response = response + "\"" + azColName[i] + "\": " + " \"" + argv[i] + "\", ";
            if (i == argc - 1)
            {
                response = response + "\" " + azColName[i] + "\": " + " \" " + argv[i] + "\"";
            }
        }

    }
    response = response + "}";
    Serial.print("Printing response: ");
    Serial.print(response);
    if (functionCalled)
    {
        response = "{";
    }
    Serial.printf("\n");
    return 0;
}

int db_open(const char* filename, sqlite3** db)
{
    int rc = sqlite3_open(filename, db);
    if (rc)
    {
        Serial.printf("Can't open database: %s\n", sqlite3_errmsg(*db));
        return rc;
    }
    else
    {
        Serial.printf("Opened database successfully\n");
    }
    return rc;
}

char* zErrMsg = 0;
int db_exec(sqlite3* db, const char* sql)
{
    Serial.print("Printing SQL: ");
    Serial.print(sql);
    Serial.print("\n");
    long start = micros();
    int rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
    if (rc != SQLITE_OK)
    {
        Serial.printf("SQL error: %s\n", zErrMsg);
        sqlite3_free(zErrMsg);
    }
    else
    {
        Serial.printf("Operation done successfully\n");
    }
    Serial.print(F("Time taken:"));
    Serial.println(micros() - start);
    return rc;
}

void setup()
{
    Serial.begin(115200);
    Serial.println("Starting...");
    SPIFFS.begin();


    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED)
    {
        Serial.print(".");
        delay(500);
    }
    Serial.println("");
    Serial.print("IP Address: ");
    Serial.println(WiFi.localIP());

    server.on("/", GetIndexPage);
    server.on("/LogIn", LogIn);

    server.begin();

    system_update_cpu_freq(SYS_CPU_160MHZ);

    if (!SPIFFS.begin())
    {
        Serial.println("Failed to mount file system");
        return;
    }
    // see all files in SPIFFS memory   
    Dir dir = SPIFFS.openDir("");
    while (dir.next())
    {
        Serial.println(dir.fileName());
        Serial.println(dir.fileSize());
    }
    // remove existing file
    SPIFFS.remove("/VendingMachineDB.db");

    sqlite3_initialize();

    // Open databases
    File db_file_obj_1;
    vfs_set_spiffs_file_obj(&db_file_obj_1);
    if (db_open("/FLASH/VendingMachineDB.db", &db1))
        return;

    //CREATE DB
    rc = db_exec(db1, createTableUser);
    if (rc != SQLITE_OK)
    {
        sqlite3_close(db1);
        //  sqlite3_close(db2);
        return;
    }
    //Inserting first user
    rc = db_exec(db1, insertUser);
    if (rc != SQLITE_OK)
    {
        sqlite3_close(db1);
        return;
    }

    //Inserting second user
    rc = db_exec(db1, insertUser2);
    if (rc != SQLITE_OK)
    {
        sqlite3_close(db1);
        return;
    }

    //SELECT USERS
    rc = db_exec(db1, sqlAllUsers);
    if (rc != SQLITE_OK)
    {
        sqlite3_close(db1);
        //  sqlite3_close(db2);
        return;
    }
}


void loop()
{
    server.handleClient();
}

//------------------------------------FUNCTIONS------------------------------------------
void LogIn()
{
    //take credentials from web page
    String UserCNP = server.arg("Username");
    String UserPassword = server.arg("Password");
    //printing in serial monitor to make sure everything looks ok
    Serial.print("\nCNP: ");
    Serial.print(UserCNP.c_str());
    Serial.print("\nUser's Password is ");
    Serial.print(UserPassword.c_str());
    Serial.print("\n");

    sprintf(buffer, "SELECT CNP, FirstName, LastName from Users WHERE (CNP='%s') AND (Password='%s');", UserCNP.c_str(), UserPassword.c_str());
    const  char* persQuery = buffer;
    rc = db_exec(db1, persQuery);
    if (rc != SQLITE_OK)
    {
        sqlite3_close(db1);
        //  sqlite3_close(db2);
        return;
    }
    server.send(200, "application/json", response);
}

Thanks, I've read the post but the thing is my loop has only the server.handleClient(); , so I don't think that it's the problem.

I'm not sure. Perhaps that call takes too long?

What do you see on the serial console? Maybe there are some clues there.

That's what appears on my serial monitor:

.............
IP Address: *myIpAdress*
/ico.ico
67646
/index.html
56635
/VendingMachineDB.db
1024
Opened database successfully
Printing SQL: CREATE TABLE Users (CNP INTEGER PRIMARY KEY, FirstName VARCHAR2(16), LastName VARCHAR2(16), Password VARCHAR2(12) NOT NULL,PhoneNumber VARCHAR2(10), Email VARCHAR2(16), TagNumber VARCHAR2(16), Credit NUMBER(4,2) NOT NULL, IsAdmin NUMBER(1) NOT NULL, IsActive NUMBER(1) NOT NULL);
Operation done successfully
Time taken:70191
Printing SQL: INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (19712073264,'Ion', 'Vasilescu', 'abc', 4.85, 1, 1);
Operation done successfully
Time taken:34334
Printing SQL: INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (29210144293, 'Maria', 'Ionescu', '346456',2.20, 0, 1 );
Operation done successfully
Time taken:34422
Printing SQL: SELECT * FROM Users;
Callback function called: 
CNP = 19712073264
FirstName = Ion
LastName = Vasilescu
Password = abc
PhoneNumber = NULL
Email = NULL
TagNumber = NULL
Credit = 4.85
IsAdmin = 1
IsActive = 1
Printing response: {"CNP":  "19712073264", "FirstName":  "Ion", "LastName":  "Vasilescu", "Password":  "abc", "Credit":  "4.85", "IsAdmin":  "1", "IsActive":  "1", " IsActive":  " 1"}
Callback function called: 
CNP = 29210144293
FirstName = Maria
LastName = Ionescu
Password = 346456
PhoneNumber = NULL
Email = NULL
TagNumber = NULL
Credit = 2.2
IsAdmin = 0
IsActive = 1
Printing response: {"CNP":  "29210144293", "FirstName":  "Maria", "LastName":  "Ionescu", "Password":  "346456", "Credit":  "2.2", "IsAdmin":  "0", "IsActive":  "1", " IsActive":  " 1"}
Operation done successfully
Time taken:64116

CNP: 19712073264
User's Password is abc
Printing SQL: SELECT CNP, FirstName, LastName from Users WHERE (CNP='19712073264') AND (Password='abc');

Exception (0):
epc1=0xc1127108 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3fff5ab0 end: 3fff6180 offset: 01a0

>>>stack>>>
3fff5c50:  3fff48ab 3ffe8c20 000002a0 40205cb0  
3fff5c60:  3fff72ec 3fff856c 000002a0 4023a487  
3fff5c70:  00000005 3fff856c 3fffadcc 4023a663  
3fff5c80:  00000002 00000004 00000003 40239b7b  
3fff5c90:  3fffabac 00000200 3fff80ec 00000200  
3fff5ca0:  00000001 00000000 00000200 00000200  
3fff5cb0:  3fff80ec 00000002 3fffadcc 402349c0  
3fff5cc0:  00000002 00000002 3ffe8c20 402144f9  
3fff5cd0:  3fff5d10 00000002 3fff81fc 00000000  
3fff5ce0:  00000000 00000148 00000148 3fff8024  
3fff5cf0:  3fffa1f0 00000000 3fffa17c 40234cc4  
3fff5d00:  757e3c9e 0000000a 00000001 40213e3b  
3fff5d10:  3fffadcc 0000000a 3fffa304 3fffa30f  
3fff5d20:  00000002 00000000 0000000a 00000000  
3fff5d30:  3fffa30e 00000000 40201779 3fffa17c  
3fff5d40:  3fff8f80 00000000 3fffa17c 40214200  
3fff5d50:  3fffa30f 00000000 00000000 40216d1a  
3fff5d60:  00000000 3fff5d90 00000009 4020adfc  
3fff5d70:  00000000 3fff5dc0 00000004 00000004  
3fff5d80:  00000001 00000001 96ee5e30 40202574  
3fff5d90:  96ee5e30 00000004 78c00000 42125bb9  
3fff5da0:  3fff8f80 3fff924c 00000000 00000000  
3fff5db0:  3fff8f80 3fffa0fc 00000000 40226a86  
3fff5dc0:  00000000 00000000 00000000 00000000  
3fff5dd0:  00000001 00000000 00000000 00000000  
3fff5de0:  00000000 00000000 00000000 00000000  
3fff5df0:  00000000 00000000 00000000 00000000  
3fff5e00:  00000000 0000ffff 00000000 00000001  
3fff5e10:  00000002 00000000 3f010003 00000000  
3fff5e20:  3fff974c 3fff7d94 3fff9224 3fff7ff4  
3fff5e30:  00000000 00000006 3fff8f44 00000000  
3fff5e40:  3f000002 00000000 00000006 00000004  
3fff5e50:  00000007 00000001 3fff2938 4023e2bc  
3fff5e60:  00007fff 0185f209 3fff3360 402439e0  
3fff5e70:  96ee5e30 00000004 3fff5f00 4023fa31  
3fff5e80:  00007fff 3fff7c24 3fff5eb0 00000100  
3fff5e90:  7fffffff 3ffef75c 3ffef75c 00000000  
3fff5ea0:  3fff974c 3fff7d94 3fff7d94 402282ce  
3fff5eb0:  00000003 0185f209 00002200 4000050c  
3fff5ec0:  3ffe8304 40101f94 00000002 00000022  
3fff5ed0:  3ffef768 3ffe9259 3fff6640 4024b734  
3fff5ee0:  00000000 00000000 0000001f 3ffe9259  
3fff5ef0:  3fff48b1 00000001 00000000 00000000  
3fff5f00:  00000000 00000000 3fff48b2 00000000  
3fff5f10:  00000000 00000000 00000000 00000000  
3fff5f20:  00000000 00000000 00000000 00000000  
3fff5f30:  00000032 00000001 3fff512c 4023baa1  
3fff5f40:  3fff5fd0 00000000 3fff9730 3fffa604  
3fff5f50:  00000010 3fff5ff0 00000000 ffffffff  
3fff5f60:  3fff7d94 3fff4858 3fff5fd0 4022d00a  
3fff5f70:  3fff5fd4 00000003 3fff5ff0 32000003  
3fff5f80:  00000001 00000000 3ffe9145 40237efc  
3fff5f90:  00000033 3fff476c 3fff512c 3fff4858  
3fff5fa0:  00000053 00000000 3fff7d94 4022d190  
3fff5fb0:  3fff5fd4 7fffffff 3fff512c 00000000  
3fff5fc0:  00000000 00000000 3fff7d94 402283ff  
3fff5fd0:  3fff974c 3fff48b2 3fff605c 40237efc  
3fff5fe0:  00000003 00000000 3fff4768 40235854  
3fff5ff0:  0000000c 3ffe940c 0000001c 4023ee90  
3fff6000:  3ffe92a8 00000008 3fff512c 0186f23a  
3fff6010:  3fff4858 3fff4768 3fff512c 40235a27  
3fff6020:  3fff7d94 3fff476c 3fff6e0c 3fff7c24  
3fff6030:  6000001c ff000000 3fff512c 40237efc  
3fff6040:  3fff4858 3fff476c 3fff4c40 40235bc4  
3fff6050:  00000000 00000000 00000000 3fff7c24  
3fff6060:  0000000f 00000003 3fff6e0c 0000000f  
3fff6070:  0000000b 000000df 000000df 4010020c  
3fff6080:  00000001 00000001 3fff78ac 4023e65e  
3fff6090:  00000000 00000000 3fff78ac 40237ef2  
3fff60a0:  3fff78ac 3fff47b0 3fff78ac 40237f2e  
3fff60b0:  00000000 00000000 00000000 4023ccdc  
3fff60c0:  3fff78ac 3fff47b0 3fff476c 40237fc2  
3fff60d0:  3fffa654 0000000f 00000006 3fff4794  
3fff60e0:  3fff4818 00000001 4023d52c 3fff5160  
3fff60f0:  3ffe9144 00000000 40237384 0000000f  
3fff6100:  00000001 3fff5158 4023d52c 3fff5160  
3fff6110:  00000000 3fff9ffc 3fff476c 3fff5158  
3fff6120:  00000001 3fff4794 3fff476c 402381d8  
3fff6130:  40107658 00000000 00001388 00000000  
3fff6140:  00000000 3fff9ffc 3fff7994 feefeffe  
3fff6150:  3fffdad0 00000000 3fff5150 40235f08  
3fff6160:  3fffdad0 00000000 3fff5150 4023d578  
3fff6170:  feefeffe feefeffe 3fff5160 4010071c  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v614f7c32
~ld
Starting...
...................
IP Address: *myIpAdress*
/ico.ico
67646
/index.html
56635
/VendingMachineDB.db
1024
Opened database successfully
Printing SQL: CREATE TABLE Users (CNP INTEGER PRIMARY KEY, FirstName VARCHAR2(16), LastName VARCHAR2(16), Password VARCHAR2(12) NOT NULL,PhoneNumber VARCHAR2(10), Email VARCHAR2(16), TagNumber VARCHAR2(16), Credit NUMBER(4,2) NOT NULL, IsAdmin NUMBER(1) NOT NULL, IsActive NUMBER(1) NOT NULL);
Operation done successfully
Time taken:71393
Printing SQL: INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (19712073264,'Ion', 'Vasilescu', 'abc', 4.85, 1, 1);
Operation done successfully
Time taken:34854
Printing SQL: INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (29210144293, 'Maria', 'Ionescu', '346456',2.20, 0, 1 );
Operation done successfully
Time taken:34383
Printing SQL: SELECT * FROM Users;
Callback function called: 
CNP = 19712073264
FirstName = Ion
LastName = Vasilescu
Password = abc
PhoneNumber = NULL
Email = NULL
TagNumber = NULL
Credit = 4.85
IsAdmin = 1
IsActive = 1
Printing response: {"CNP":  "19712073264", "FirstName":  "Ion", "LastName":  "Vasilescu", "Password":  "abc", "Credit":  "4.85", "IsAdmin":  "1", "IsActive":  "1", " IsActive":  " 1"}
Callback function called: 
CNP = 29210144293
FirstName = Maria
LastName = Ionescu
Password = 346456
PhoneNumber = NULL
Email = NULL
TagNumber = NULL
Credit = 2.2
IsAdmin = 0
IsActive = 1
Printing response: {"CNP":  "29210144293", "FirstName":  "Maria", "LastName":  "Ionescu", "Password":  "346456", "Credit":  "2.2", "IsAdmin":  "0", "IsActive":  "1", " IsActive":  " 1"}
Operation done successfully
Time taken:64104

The Exception(0) appears after I press the button on the web page.
And this is the console log output of the web page after I press the button

Judging from the serial output, this could be the offending line:

int rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);

Can you add some timing information? E.g.,

Serial.println(millis());
int rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
Serial.println(millis());

Now it looks like this:

IP Address: *myIpAdress*
/ico.ico
67646
/index.html
56635
/VendingMachineDB.db
1024
Opened database successfully
Printing SQL: CREATE TABLE Users (CNP INTEGER PRIMARY KEY, FirstName VARCHAR2(16), LastName VARCHAR2(16), Password VARCHAR2(12) NOT NULL,PhoneNumber VARCHAR2(10), Email VARCHAR2(16), TagNumber VARCHAR2(16), Credit NUMBER(4,2) NOT NULL, IsAdmin NUMBER(1) NOT NULL, IsActive NUMBER(1) NOT NULL);
19326
19396
Operation done successfully
Time taken:70834
Printing SQL: INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (19712073264,'Ion', 'Vasilescu', 'abc', 4.85, 1, 1);
19403
19438
Operation done successfully
Time taken:35091
Printing SQL: INSERT INTO Users (CNP, FirstName, LastName, Password, Credit, isAdmin, isActive) VALUES (29210144293, 'Maria', 'Ionescu', '346456',2.20, 0, 1 );
19446
19480
Operation done successfully
Time taken:35095
Printing SQL: SELECT * FROM Users;
19481
Callback function called: 
CNP = 19712073264
FirstName = Ion
LastName = Vasilescu
Password = abc
PhoneNumber = NULL
Email = NULL
TagNumber = NULL
Credit = 4.85
IsAdmin = 1
IsActive = 1
Printing response: {"CNP":  "19712073264", "FirstName":  "Ion", "LastName":  "Vasilescu", "Password":  "abc", "Credit":  "4.85", "IsAdmin":  "1", "IsActive":  "1", " IsActive":  " 1"}
Callback function called: 
CNP = 29210144293
FirstName = Maria
LastName = Ionescu
Password = 346456
PhoneNumber = NULL
Email = NULL
TagNumber = NULL
Credit = 2.2
IsAdmin = 0
IsActive = 1
Printing response: {"CNP":  "29210144293", "FirstName":  "Maria", "LastName":  "Ionescu", "Password":  "346456", "Credit":  "2.2", "IsAdmin":  "0", "IsActive":  "1", " IsActive":  " 1"}
19543
Operation done successfully
Time taken:65423

CNP: 19712073264
User's Password is abc
Printing SQL: SELECT CNP, FirstName, LastName from Users WHERE (CNP='19712073264') AND (Password='abc');
64445

Exception (0):
epc1=0xc1127108 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3fff5ab0 end: 3fff6180 offset: 01a0

>>>stack>>>
3fff5c50:  3fff48ab 3ffe8c20 000002a0 40205cb0  
3fff5c60:  3fff72ec 3fff856c 000002a0 4023a4a7  
3fff5c70:  40103e1b 3fff856c 3fffadcc 4023a683  
3fff5c80:  00000002 00000004 00000003 40239b9b  
3fff5c90:  3fffabac 00000200 3fff80ec 00000200  
3fff5ca0:  00000001 00000000 00000200 00000200  
3fff5cb0:  3fff80ec 00000002 3fffadcc 402349c0  
3fff5cc0:  00000002 00000002 3ffe8c20 402144f9  
3fff5cd0:  3fff5d10 00000002 3fff81fc 00000000  
3fff5ce0:  00000000 00000148 00000148 3fff8024  
3fff5cf0:  3fffa248 00000000 3fffa1d4 40234cc4  
3fff5d00:  757e3c9e 0000000a 00000001 40213e3b  
3fff5d10:  3fffadcc 0000000a 3fffa304 3fffa30f  
3fff5d20:  00000002 00000000 0000000a 00000000  
3fff5d30:  3fffa30e 00000000 40201779 3fffa1d4  
3fff5d40:  3fff8f80 00000000 3fffa1d4 40214200  
3fff5d50:  3fffa30f 00000000 00000000 40216d1a  
3fff5d60:  00000000 3fff5d90 00000009 4020adfc  
3fff5d70:  00000000 3fff5dc0 00000004 00000004  
3fff5d80:  00000001 00000001 96ee5e30 40202574  
3fff5d90:  96ee5e30 00000004 78c00000 42125bb9  
3fff5da0:  3fff8f80 3fff924c 00000000 00000000  
3fff5db0:  3fff8f80 3fffa154 00000000 40226a86  
3fff5dc0:  00000000 00000000 00000000 00000000  
3fff5dd0:  00000001 00000000 00000000 00000000  
3fff5de0:  00000000 00000000 00000000 00000000  
3fff5df0:  00000000 00000000 00000000 00000000  
3fff5e00:  00000000 0000ffff 00000000 00000001  
3fff5e10:  00000002 00000000 3f010003 00000000  
3fff5e20:  3fff97c4 3fff7d94 3fff9224 3fff7ff4  
3fff5e30:  00000000 00000006 3fff8f44 00000000  
3fff5e40:  3f000002 00000000 00000006 00000004  
3fff5e50:  00000007 00000001 3fff28e8 4023e2dc  
3fff5e60:  3fff96bc 401043ee 3fff7d4c 40243a00  
3fff5e70:  96ee5e30 00000004 3fff5f00 4023fa51  
3fff5e80:  3ffeeed5 3fff8f04 3fff5eb0 00000001  
3fff5e90:  40101be9 3fff28e8 3ffef021 00000000  
3fff5ea0:  3fff97c4 3fff7d94 3fff7d94 402282ce  
3fff5eb0:  00000003 00000000 00000000 3fff2668  
3fff5ec0:  3ffe8304 03d65327 00000002 00000100  
3fff5ed0:  7fffffff 3ffe9259 3ffef78c 00000001  
3fff5ee0:  00000000 00000000 0000001f 3ffe9259  
3fff5ef0:  3fff48b1 00000001 00000000 00000000  
3fff5f00:  00000000 00000000 3fff48b2 00000000  
3fff5f10:  00000000 00000000 00000000 00000000  
3fff5f20:  00000000 00000000 00000000 00000000  
3fff5f30:  00000032 00000001 3fff512c 4023bac1  
3fff5f40:  3fff5fd0 00000000 3fff97c8 3fffa604  
3fff5f50:  00000010 00000004 3fff5fbf ffffffff  
3fff5f60:  3fff7d94 3fff4858 3fff5fd0 4022d00a  
3fff5f70:  3fff5fd4 0000000a 3fff512c 4023bac1  
3fff5f80:  00000001 00000000 3ffe9145 40237f1c  
3fff5f90:  00000033 3fff476c 3fff5fba 3fff4858  
3fff5fa0:  00000053 00000000 3fff7d94 4022d190  
3fff5fb0:  3fff5fd4 00000001 3ffe9145 00000000  
3fff5fc0:  00000000 00000000 3fff7d94 402283ff  
3fff5fd0:  3fff97c4 3fff48b2 3fff512c 4023bac1  
3fff5fe0:  00000003 00000000 3fff4768 40235854  
3fff5ff0:  0000000c 3ffe940c 0000001c 4023c7fc  
3fff6000:  3ffe92a8 00000008 3fff512c 03d75b67  
3fff6010:  3fff4858 3fff4768 3fff512c 40235a3a  
3fff6020:  3fff7d94 3fff476c 3fff6e3c 3fff8f04  
3fff6030:  6000001c ff000000 3fff512c 40237f1c  
3fff6040:  3fff4858 3fff476c 3fff4c40 40235be8  
3fff6050:  00000000 00000000 00000000 3fff8f04  
3fff6060:  0000000f 00000003 3fff6e3c 0000000f  
3fff6070:  0000000b 00000810 00000810 4010020c  
3fff6080:  00000001 00000001 3fff78ac 4023e67e  
3fff6090:  00000000 00000000 3fff78ac 40237f12  
3fff60a0:  3fff78ac 3fff47b0 3fff78ac 40237f4e  
3fff60b0:  00000000 00000000 00000000 4023ccfc  
3fff60c0:  3fff78ac 3fff47b0 3fff476c 40237fe2  
3fff60d0:  3fffa654 0000000f 00000006 3fff4794  
3fff60e0:  3fff4818 00000001 4023d54c 3fff5160  
3fff60f0:  3ffe9144 00000000 402373a4 0000000f  
3fff6100:  00000001 3fff5158 4023d54c 3fff5160  
3fff6110:  00000000 3fff9ffc 3fff476c 3fff5158  
3fff6120:  00000001 3fff4794 3fff476c 402381f8  
3fff6130:  40107658 00000000 00001388 00000000  
3fff6140:  00000000 3fff9ffc 3fff7994 feefeffe  
3fff6150:  3fffdad0 00000000 3fff5150 40235f2c  
3fff6160:  3fffdad0 00000000 3fff5150 4023d598  
3fff6170:  feefeffe feefeffe 3fff5160 4010071c  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

So that is indeed where it crashes. My guess is that the sqlite3_exec() call takes too long, after which the watchdog timer kicks in and resets the board. Of course, I could be completely wrong here.

It appears so.Thanks for the help.Have any suggestion for the fix?I can't think of anything else but this instruction.

Not really, I haven't done much with watchdog timers myself.

I would probably try to disable the watchdog timer to see if it makes any difference. If it does I would try to figure out how to set the timeout to a more sensible value.

There is an exception decoder that will make the exception output more user friendly. I have no experience with it and no idea if it needs to be installed or not; your search engine is your friend.

I've searched a little bit on the internet and found this guy here saying that it's not a good ideea to disable the watchdog, so I won't 'cause I did't interactionate much with this subject.I'll keep trying to solve the problem and if I'll find a solution I'll post it here.Thanks for your help.

I never said it was a good idea, but it might help you to find the cause of the problem.

Yes, I found it in this post.I'll try it and come back with an answer.
That's the link of the Exception Stack Trace Decoder for anyone reading this post in the future, maybe it helps.

I found the problem. File db_file_obj_1; was declared in setup so for some reason my Test function was getting crazy because it didn't find it.If you ever run into this problem please check if this was declared globally and also check if the db was closed(and reopen it into that function like this: vfs_set_spiffs_file_obj(&db_file_obj_1); if (db_open("/FLASH/test1.db", &db1)) return;)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.