Picture of Rico 1837
Registered 10 years 302 days
Rico 1837 Friday, 2 July 2021, 01:20 PM
[GenericApp] SEGFAULT in Database.exec()
Maybe i am wrong, but:

Database.exec("UPDATE demo SET content='"+ Database.escape(obj.content) + "' WHERE id="+ Database.escape(obj.id);)


given this code, the generic app crashes with segfault when obj.content is too long.

to reproduce you can use the attached demo app.

use the button "insert" to create an db entry. with "update ok" the maximum, not crashing 'content' is updated to this entry. with "update failed", one char is added to the same content var as before. But this time the app crashes. In dev and rel versions of the "13r2 136094 final" binary at a IP411.


07-02 10:58:47.601 dumping stack trace from core dump /var/log/core_dumps/segfaultdbdemo/segfaultdbdemo.core.dump (current build:136094)

[New LWP 6973]
[New LWP 6974]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Core was generated by `/apps/segfaultdbdemo/segfaultdbdemo --manager=/var/run/manager/manager --servic'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x74696c64 in ?? ()
[Current thread is 1 (Thread 0x76ff3c10 (LWP 6973))]

Thread 2 (Thread 0x766c5410 (LWP 6974)):
#0 0x76fabf28 in pthread_cond_wait@@GLIBC_2.4 () from /lib/libpthread.so.0
#1 0x000620b8 in Dns::ThreadFunction() ()
#2 0x00061e4c in __dns_thread_main(void*) ()
#3 0x76fa37ac in start_thread () from /lib/libpthread.so.0
#4 0x767f5368 in ?? () from /lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0x76ff3c10 (LWP 6973)):
#0 0x74696c64 in ?? ()
#1 0x00051500 in AppWebsocket::WebsocketRecvResult(IWebsocket*, void*, unsigned int, bool, bool) ()
#2 0x000a821c in WebserverWebsocketHandler::HandleMessage(IWebserverMessage*, void*, unsigned int) ()
#3 0x0009fa5c in WebserverPlugin::SocketRecvResult(ISocket*, void*, unsigned int) ()
#4 0x00074728 in UDSocket::ReceiveData() ()
#5 0x00074ca8 in UDSocket::IoContextNotify(bool, bool) ()
#6 0x0004b3d8 in IoMux::Run() ()
#7 0x00017904 in main ()

segfault_db_demo.zip
Andreas Fink
Moderator Registered 13 years 109 days
Andreas Fink (innovaphone) Friday, 2 July 2021, 02:36 PM
Re: [GenericApp] SEGFAULT in Database.exec()
Thank you for the nice error report, I have forwarded it to development. A fix could be expected with the next service release.
Picture of Matthias Schertler (innovaphone)
Moderator Registered 12 years 192 days
Matthias Schertler (innovaphone) Tuesday, 13 July 2021, 12:17 AM in response to Rico 1837
Re: [GenericApp] SEGFAULT in Database.exec()
Thanks Rico, there will be a fix in the next service release.

BR
Matthias
← You can define your color theme preference here