sqlpp11: how to fix update exception?

CREATE TABLE users (
    id        INTEGER PRIMARY KEY AUTOINCREMENT,
    pid       INTEGER,
    user_id   TEXT,
    user_name TEXT,
    passwd    TEXT
);
db(update(user).set(user.userName = "test",user.passwd = "test").where(user.userId == "123"));

on sqlite

update other table exception too.

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 23 (15 by maintainers)

Most upvoted comments

I don’t have mingw on my Windows 10 machine at the moment, so I cannot test it.

My prime suspect is the sqlite3 library that is linked to your app. You may want to check if the sqlite3 headers are for the same version as the sqlite library that you are linking to your executable. Also make sure that the sqlite3 library uses the same CRT DLL as your main executable, so that you don’t have two memory heaps. Maybe try using http://dependencywalker.com/ or another similar tool to check if the main executable and the sqlite3 library use the same CRT DLL.

@shishirong

I could not find any obvious problems after looking at your source code.

So I built your project on latest Fedora 39. I had to rename DBModels.h -> DbModels.h because of filesystem case-sensitivity, but other than that, building the project went OK. After running the built executable it also worked fine and exited normally.

What platform (OS, compiler version, SQLite3 version, sqlpp11 version) are you building/running your demo on?

The error that you are getting std::bad_alloc, which implies some kind of memory problem, you are running out of memory or getting heap corruption.

I would check for a mismatch between sqlite3 library headers and the corresponding sqlite3 dynamic/static library. If that is OK, then probably the most straightforward approach would be to run it under your platform debugger to see where it throws std::bad_alloc and if there is any platform-specific error that is mapped to std::bad_alloc. If that doesn’t help, then it probably makes sense to run it under a memory debugger like Valgrind.