Skip to content
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

Prepare query failed: what(): out of memory #22

Open
jamjpan opened this issue Jan 31, 2019 · 0 comments
Open

Prepare query failed: what(): out of memory #22

jamjpan opened this issue Jan 31, 2019 · 0 comments

Comments

@jamjpan
Copy link
Owner

jamjpan commented Jan 31, 2019

Prepare query failed:
select route, idx_last_visited_node, next_node_distance from vehicles where  id = ?
terminate called after throwing an instance of 'std::runtime_error'
  what():  out of memory
Aborted (core dumped)

Reason:

An RSAlgorithm class is initialized before a Cargo class. The RSAlgorithm class tries to prepare statements against the Cargo DB, but the DB is not created yet. sqlite3_errmsg in dbsql.cc > prepare_stmt(2) receives a bad pointer, hence we get a misleading error message (see https://stackoverflow.com/questions/43321649/failed-from-sqlite3-prepare-v2-error-is-out-of-memory).

Workaround:

Initialize Cargo before RSAlgorithm. For example:

/* BAD */
MyAlg A;  // extends RSAlgorithm
Cargo(options);

/* GOOD */
Cargo(options);
MyAlg A;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant