On Jan 26, 2010, at 6:16 AM, Kavita Raghunathan wrote:

> Following Sql query crashes in allocateCursor inside of sqlite3_step
>
> INSERT INTO EntityTbl (AttrName, AttrEnum, AttrType, AttrValue,  
> ReadWrite, Entity_id) VALUES(‘image_crc’, 6008, 16, ‘0’, 1, 34013184);
>
> I’m not able to get an understanding of what I might be doing wrong.
> Please note:
>
> 1.  I have successfully created EntityTbl
> 2.  I have added n rows successfully into table this is row n+1 that  
> causes a crash
> 3.  I know previously this group asked me to use valgrind to see if  
> the crash was elsewhere and I did that. I’ve enclosed the results.

The valgrind output seems to indicate the problem is not in SQLite, no?
Function get_default_database() has a buffer overrun in it.

>
> Thanks,
> Kavita
>
> ==28525== Memcheck, a memory error detector
> ==28525== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward  
> et al.
> ==28525== Using Valgrind-3.5.0 and LibVEX; rerun with -h for  
> copyright info
> ==28525== Command: cm
> ==28525==
> updating hw address
> sh: ifconfig: command not found
> ==28525== Syscall param write(buf) points to uninitialised byte(s)
> ==28525==    at 0x62A44B: ??? (in /lib/libpthread-2.5.so)
> ==28525==    by 0x80661F3: unixWrite (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x805F1A3: sqlite3OsWrite (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x8069E19: writeJournalHdr (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x806D416: pager_open_journal (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x806D4E1: sqlite3PagerBegin (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x8071BB3: sqlite3BtreeBeginTrans (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80852F5: sqlite3VdbeExec (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x808084F: sqlite3Step (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x8080A00: sqlite3_step (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80C2866: sf_database_mgr::set_cache_size(sqlite3*,  
> int) (in /home/kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80C2AF4:  
> sf_database_mgr::create_database(sqlite3**, char const*) (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==  Address 0x40757b9 is 9 bytes inside a block of size 2,056  
> alloc'd
> ==28525==    at 0x4005903: malloc (vg_replace_malloc.c:195)
> ==28525==    by 0x805F746: sqlite3MemMalloc (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x8060062: mallocWithAlarm (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x806010A: sqlite3Malloc (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80683CD: pcache1Alloc (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x8068541: sqlite3PageMalloc (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x806BA08: sqlite3PagerSetPagesize (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80713A2: sqlite3BtreeSetPageSize (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80A3BF5: sqlite3Pragma (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80BDA6A: yy_reduce (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80BE3CF: sqlite3Parser (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80BF01E: sqlite3RunParser (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==
> ==28525== Use of uninitialised value of size 4
> ==28525==    at 0x4007D3C: strcpy (mc_replace_strmem.c:303)
> ==28525==    by 0x804FEB9:  
> fls_entity::get_default_database(sf_db_tbl_t**) (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804B4E6:  
> cm_entity_manager::update_entity_database(sf_entity*) (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804B601:  
> cm_entity_manager::update_entity_database() (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804BB59:  
> cm_entity_manager::do_init_database(char*) (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804BCDC: cm_entity_manager::cm_entity_manager()  
> (in /home/kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80499FD: main (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==
> ==28525== Invalid write of size 1
> ==28525==    at 0x4007D3C: strcpy (mc_replace_strmem.c:303)
> ==28525==    by 0x804FEB9:  
> fls_entity::get_default_database(sf_db_tbl_t**) (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804B4E6:  
> cm_entity_manager::update_entity_database(sf_entity*) (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804B601:  
> cm_entity_manager::update_entity_database() (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804BB59:  
> cm_entity_manager::do_init_database(char*) (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804BCDC: cm_entity_manager::cm_entity_manager()  
> (in /home/kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80499FD: main (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
> ==28525==
> ==28525==
> ==28525== Process terminating with default action of signal 11  
> (SIGSEGV)
> ==28525==  Access not within mapped region at address 0x0
> ==28525==    at 0x4007D3C: strcpy (mc_replace_strmem.c:303)
> ==28525==    by 0x804FEB9:  
> fls_entity::get_default_database(sf_db_tbl_t**) (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804B4E6:  
> cm_entity_manager::update_entity_database(sf_entity*) (in /home/ 
> kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804B601:  
> cm_entity_manager::update_entity_database() (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804BB59:  
> cm_entity_manager::do_init_database(char*) (in /home/kraghunathan/ 
> views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x804BCDC: cm_entity_manager::cm_entity_manager()  
> (in /home/kraghunathan/views/sfdev-2.0/out/usr/bin/cm)
> ==28525==    by 0x80499FD: main (in /home/kraghunathan/views/ 
> sfdev-2.0/out/usr/bin/cm)
> ==28525==  If you believe this happened as a result of a stack
> ==28525==  overflow in your program's main thread (unlikely but
> ==28525==  possible), you can try to increase the size of the
> ==28525==  main thread stack using the --main-stacksize= flag.
> ==28525==  The main thread stack size used in this run was 10485760.
> ==28525==
> ==28525== HEAP SUMMARY:
> ==28525==     in use at exit: 105,223 bytes in 419 blocks
> ==28525==   total heap usage: 1,938 allocs, 1,519 frees, 1,036,909  
> bytes allocated
> ==28525==
> ==28525== LEAK SUMMARY:
> ==28525==    definitely lost: 472 bytes in 1 blocks
> ==28525==    indirectly lost: 432 bytes in 8 blocks
> ==28525==      possibly lost: 72,224 bytes in 86 blocks
> ==28525==    still reachable: 32,095 bytes in 324 blocks
> ==28525==         suppressed: 0 bytes in 0 blocks
> ==28525== Rerun with --leak-check=full to see details of leaked memory
> ==28525==
> ==28525== For counts of detected and suppressed errors, rerun with: -v
> ==28525== Use --track-origins=yes to see where uninitialised values  
> come from
> ==28525== ERROR SUMMARY: 9 errors from 3 contexts (suppressed: 17  
> from 8)
> Segmentation fault
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to