Closed DaBo-jp closed 2 years ago
for more information.
I tried theese process.
the projectname is model_sample.
thank you.
I can't find the exact position of failure from your picture. Could you post what happend in frame 0?
It's weird that you have so many RTTI symbols not found
in you backtrace. What's the version of your gcc and gdb?
One possibility was that you updated drogon, but did not build your app from the begining. If this was the case, removing the entire build dir of your app and building again might solve the problem.
Thank you for your response.
The error occurs on the orm/Mapper class in the automated code does a find. This time it's mapper.findall(), but the same if I specify an index.
mapper.findAll([req, callbackPtr, this](const std::vector<ProductMaster> &v)
go into detail, it looks like trying to remove an empty pointer when remove a reference to a smart pointer, but as you said, RTTI worning hasn't caught up well.
these are compiler and debugger details. gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
By the way, this is the Drogon repository that I'm currently using.
commit ebf87d69d7bb45dfa478ba364ef9374d9be25092 (HEAD -> master, origin/master, origin/HEAD) Author: An Tao antao2002@gmail.com Date: Sun Jun 5 21:10:42 2022 +0800
As you told me, I would like to try switching the environment first.
thank you.
hi, I tried switching the environment. but unfortunately it didn't improve.
When I tried debug-building the main unit, an assertion message came out.
drogon/lib/src/DbClientManager.h:35: drogon::orm::DbClientPtr drogon::orm::DbClientManager::getDbClient(const string&): Assertion `dbClientsMap.find(name) != dbClientsMap.end()' failed.
it's looks like connection failed with DB. Next, when I set up a container on Docker and compared the communication state when dg_ctl was execute and when the binary was execute, while monitoring the container interface with tcpdump. then the DB received the packet when dg_ctl was executed. but didn't receive the packet when I ran the binary.
Is this a clue?
thank you.
solved.
The problem was that the contents of db_clients were empty when the program was run, so When I changed to get the information of db_clients from config.json in main.cc, I was able to get the data normally.
Two questions arise here.
Isn't it cumbersome to have similar information in model.json and config.json? I feel that there is a risk of forgetting to write or inconsistency due to writing mistakes.
I'm likely to forget about this procedure, so could anyone please tell me if there is a document page that says it?
Thank you.
I guess the original problem was what I said? There is no more strange errors after building from scratch.
Isn't it cumbersome to have similar information in model.json and config.json? I feel that there is a risk of forgetting to write or inconsistency due to writing mistakes.
model.json
is a one-time config, it is used only to generate orm source files by drogon_ctl create model
. config.json
however, is a every-time config. It is used every time you start the application. They are not the same thing. And many people do not need orm, so they can remove model.json. But config.json
is always needed.
I'm likely to forget about this procedure, so could anyone please tell me if there is a document page that says it?
The config.json
file is well commented, you can get nearly all the informations in it.
And just as I just said, model.json
is just a code-generation helper, don't get confused by them.
The wiki page has more information on how to use the framework.
The RunTime Type Infomation warning is a recognition that is familiar and not a big deal. It's very common to disable RTTI as it can slow down run-time performance. and It's a gdb warning, it does not affect the execution of the program.
When using ORM, enable the following lines in main.cc after creating the project.
//drogon::app().loadConfigFile("../config.json");
You need to fill in the connection information in config.json.
The original problem is that I misunderstood that the information of model.json is reflected even when createDbClient () is executed without these recognition.
At the same time, these were the necessary information for me, who learned about the existence of this framework in the last few days. This is what you are pointing out.
model.json is a one-time config, it is used only to generate orm source files by drogon_ctl create model. config.json however, is a every-time config. It is used every time you start the application.
I'm sorry I couldn't hear it easily. Thank you for your cooperation.
hi, I need someones help. SIGSEGV was happend when i was tring to make RESTfulAPI based PostgreSQL.
Below is a sample.
tabeles.
model.json
{ "rdbms": "postgresql", //filename: sqlite3 db file name //"filename":"", //host: server address,localhost by default; "host": "127.0.0.1", //port: server port, 5432 by default; "port": 5432, //dbname: Database name; "dbname": "sample", //schema: valid for postgreSQL, "public" by default; "schema": "sample_schema", //user: User name "user": "postgres", //password or passwd: Password "password": "drogon", //client_encoding: The character set used by drogon_ctl. it is empty string by default which //means use the default character set. "client_encoding": "UTF-8", //table: An array of tables to be modelized. if the array is empty, all revealed tables are modelized. "tables": [], //convert: the value can be changed by a function call before it is stored into database or //after it is read from database "convert": { "enabled": false, "items":[{ "table": "user", "column": "password", "method": { //after_db_read: name of the method which is called after reading from database, signature: void([const] std::shared_ptr [&]) "after_db_read": "decrypt_password", //before_db_write: name of the method which is called before writing to database, signature: void([const] std::shared_ptr [&]) "before_db_write": "encrypt_password" }, "includes": [ "\"file_local_search_path.h\"","<file_in_global_search_path.h>" ] }] }, "relationships": { "enabled": true, "items": [ { "type": "has many", "original_table_name": "products", "original_table_alias": "product", "original_key": "products_category_id", "target_table_name": "categories", "target_table_alias": "category", "target_key": "category_id", "enable_reverse": true } ] }, "restful_api_controllers": { "enabled": true, // resource_uri: The URI to access the resource, the default value // is '/*' in which the asterisk represents the table name. // If this option is set to a empty string, the URI is composed of the namespaces and the class name. "resource_uri": "/*", // class_name: "Restful*Ctrl" by default, the asterisk represents the table name. // This option can contain namespaces. "class_name": "Restful*Ctrl", // filters: an array of filter names. "filters": [], // db_client: the database client used by the controller. this option must be consistent with // the configuration of the application. "db_client": { //name: Name of the client,'default' by default "name": "default", //is_fast: "is_fast": false }, // directory: The directory where the controller source files are stored. "directory": "controllers", // generate_base_only: false by default. Set to true to avoid overwriting custom subclasses. "generate_base_only": false } }
back trace
Desktop (please complete the following information):
How can I fix it ?