-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32 STACKOVERFLOW FOR SELECT QUERY #20
Comments
@siara-cc can you help me ? |
@Yukselzngn Hi, Sorry I was unable to reply earlier. There is not much to say from what you have mentioned. |
@siara-cc Thank you for response. example code: void app_main()
} I am reading data from a pre-established memory database and writing data to it as well. As wrote above, if I send a query other than a 'SELECT' statement to the table first and then send a 'SELECT' query, it works. However, if the first query sent to the database is a 'SELECT' statement, it gives an error like the one below: CODE void app_main()
} ERROR: entry 0x4008064c W (99) boot.esp32: WDT reset info: APP CPU PC=0x40087950 I (105) boot: Enabling RNG early entropy source... I (0) cpu_start: App cpu up. ERROR A stack overflow in task main has been detected. Backtrace: 0x400819c2:0x3ffbf750 0x40088c75:0x3ffbf770 0x4008b986:0x3ffbf790 0x4008a343:0x3ffbf810 0x4008bad4:0x3ffbf830 0x4008ba86:0x00000018 |<-CORRUPTED 0x40088c75: esp_system_abort at /home/yuksel/esp/esp-idf/components/esp_system/port/esp_system_chip.c:84 0x4008b986: vApplicationStackOverflowHook at /home/yuksel/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:581 0x4008a343: vTaskSwitchContext at /home/yuksel/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:3729 0x4008bad4: _frxt_dispatch at /home/yuksel/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S:450 0x4008ba86: _frxt_int_exit at /home/yuksel/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S:245 ELF file SHA256: 3ded88e7a7578bb1 Rebooting... |
@Yukselzngn If it is just about reading from a simple table it should work so the only reason for such crashes usually are memory allocation issues. There is a tool that can show the exact location of crash in the code when input with the crash dump but I have not used it much. |
Hi @Yukselzngn @siara-cc I have this same problem as well, I can create a table and insert data but a select causes a stack overflow. I'm storing the data on a SD card though but what I found is that the file created on the SD card is corrupt I think. If I insert the SD card into a PC and try to delete the file from the SD card, then I get a "Invalid file handle" error. |
Okay so I realized my mistake, the file name I used was a windows reserved name, that's why I got the "invalid file handle" error. I can confirm that I can create a database file and table as well as insert data but any kind of select causes a stack overflow. I have also tried recreating the table and database file. I Always get the same result, even if I use a database file I created on my PC. |
So digging into sqlite3_exec I found that the stack overflow occurs when sqlite3LockAndPrepare returns its result code. I can't tell why its causing a stack overflow. |
It turns out I needed a sanity check, I thought I had increased the stack size setting but it never changed. @Yukselzngn increase your main task stack size to something like 8096. My selects work after doing that |
@SpazCode153 I thought the default stack size for esp32 was 8192? Was it reduced in the recent versions? |
@siara-cc I'm using ESP-IDF V5.1 and the default setting there is 3584. Okay thank you. |
@SpazCode153 and @siara-cc thank you very much, my default stack size value was 3584, after you told me, my problem was solved when I changed it. Thank you for your advice. |
@Yukselzngn its pleasure. Enjoy your day. |
Hello Guys, Suffer from the same situation over here. Can anyone provide step by step fix for this? I also changed the page size from the library. Kind Regards, ALi |
Hi @torabian, are you sure the stack size is increased? I found that sometimes when I change the settings it doesn't always save after I actually click save. If your using VS code, try closing VS code and opening again and checking the stack size setting. What have you increased the stack size too? May I ask how much data your selecting? 1000 rows etc Also can you send your terminal output with the error here? |
@siara-cc I believe changing esp pager to 512 is a mistake. When I changed it to 512, after 3-4 subsequent db_exec I had an stack overflow, I changed it to 4096 as it was. Maybe you consider that to be reverted? |
I am running all these queries at once. It's super unreliable:
|
|
Also another issue is, if I mount the spiffs in another function, it would say IO/Write error, that's also strange. I create table 'bugg table' before each sql statement, it's really weird. I wonder, how can we have a high load example of the library, to test 100 table creation, |
I think using the sql queries inside http methods causing the problem... |
@torabian I'm just confirming, you did change the "Main task stack size" under "ESP System Settings" in your SDK config to something larger or equal to 6144? Can you perhaps paste your "sdkconfig" file here so we can see all your settings? |
I am quite tired for today, but I got good results so far - unfortunately, the mystery for me still remains, why database calls inside the http call backs are causing the stackoverflow. Inside app_main function, as many as sql queries are fine - just some times I/O error but 3 out of 100 operations. I changed stack size to 8000, maybe that helped to remove initial INSERT function. I will prepare an example tomorrow and share. @siara-cc Are you planning to make the library ready for v5 as well? It seems only 1-2 tweaks are required, maybe we can merge it into the repo? |
@torabian Sorry I saw your queries only now. SPIFFS is known to throw IO errors. Why not use LITTLEFS? |
@siara-cc Hello Arun; Sorry for late reply, I just managed to get CRU-(D?) working on the ESP32 with HTTP server support, and, this library. I have used the SPIFFS for now, it seems 95% + of time working. But I am not sure how good it keeps data, or will I be able to upload files to it. I will opened a merge request soon. |
Hello @siara-cc @SpazCode153 , Can you help me please |
Hi @Yukselzngn, Can you more or less pin point which queries are causing the timeouts? Also how large is your database in terms of file size? |
@SpazCode153 |
Can you share that snippet of code? |
int getNumberOfChargPoint(){
} db_exec function:
} calllback function: static int callback(char *tableName, int argc, char **argv, char **azColName)
} |
You cannot use callback system. You need to go the prepare sqlite3_prepare_v2 instead for long term and reliable usage. |
Hello ,
I am using your SQLite database in my ESP32 project and would like to thank you for your help. However, I ran into some problems using it and would be very grateful for your help:
I store the data in SPIFFS and it works fine when I use it as in the example. But I want to preserve the previous data by not rebuilding the database every time I run the program. For this purpose I am removing the unlink function and not creating a "CREATE " query, I just want to query the data using "SELECT" to read it. But when I do this I get a stack overflow error and the ESP restarts.
It works when the first query is "CREATE", "INSERT" , "DROP" or "UPDATE". But when the first 'SELECT' is flood t, I get a stackoverflow error.
I would be very grateful if you could help me.
Kind regards
The text was updated successfully, but these errors were encountered: