zussel / matador

Take your appclication by the horns
http://zussel.github.io/matador
GNU General Public License v3.0
63 stars 22 forks source link

some fileds will not store in db, when create table will abort. read db normally #120

Closed suisou closed 4 years ago

suisou commented 4 years ago

my app Aborted at this row. persistence p(MYSQL_LINK);

SQL: CREATE TABLE mediaserver_conf (id BIGINT NOT NULL PRIMARY KEY, DEV_NAME VARCHAR(255), strVhost VARCHAR(255), strApp VARCHAR(255), strId VARCHAR(255), wchannel INTEGER, dwStreamType INTEGER UNSIGNED, fDuration DOUBLE, bEanbleRtsp INTEGER, bEanbleRtmp INTEGER, bEanbleHls INTEGER, bEnableMp4 INTEGER, bUseAsynLogin INTEGER, wPort INTEGER, sDeviceAddress VARCHAR(255), sUserName VARCHAR(255), sPassword VARCHAR(255)) SQL: START TRANSACTION SQL: INSERT INTO mediaserver_conf (id, DEV_NAME, strVhost, strApp, strId, wchannel, dwStreamType, fDuration, bEanbleRtsp, bEanbleRtmp, bEanbleHls, bEnableMp4, bUseAsynLogin, wPort, sDeviceAddress, sUserName, sPassword) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) SQL: COMMIT free(): invalid pointer

libc.so.6!raise 
libc.so.6!abort 
libc.so.6!__libc_message    
libc.so.6!malloc_printerr   
libc.so.6!_int_free 
matador::object_proxy::destroy<s_mediaserverconf>(void * p) Line 372    C++
libmatador-object.so.0!matador::object_proxy::~object_proxy()   
libmatador-object.so.0!matador::prototype_node::clear(bool) 
libmatador-object.so.0!matador::object_store::remove_prototype_node(matador::prototype_node*, bool) 
libmatador-object.so.0!matador::object_store::clear(bool)   
libmatador-object.so.0!matador::object_store::~object_store()   
libmatador-orm.so.0!matador::persistence::~persistence()    

CreateTable() Line 103 C++

struct s_mediaserverconf { ///id identifier id; char DEV_NAME[255]; char strVhost[255]; char strApp[255]; char strId[255]; int wchannel; DWORD dwStreamType;

double   fDuration;
int     bEanbleRtsp;
int     bEanbleRtmp;
int     bEanbleHls;
int     bEnableMp4;
int     bUseAsynLogin;
int     wPort;
char    sDeviceAddress[255];
char    sUserName[255];
char    sPassword[255];

template < class SERIALIZER >
void serialize(SERIALIZER& serializer) {
    serializer.serialize("id", id);
    serializer.serialize("DEV_NAME", DEV_NAME,255);
    serializer.serialize("strVhost", strVhost, 255);
    serializer.serialize("strApp", strApp, 255);
    serializer.serialize("strId", strId, 255);
    serializer.serialize("wchannel", wchannel);
    serializer.serialize("dwStreamType", dwStreamType);
    serializer.serialize("fDuration", fDuration);
    serializer.serialize("bEanbleRtsp", bEanbleRtsp);
    serializer.serialize("bEanbleRtmp", bEanbleRtmp);
    serializer.serialize("bEanbleHls", bEanbleHls);
    serializer.serialize("bEnableMp4", bEnableMp4);
    serializer.serialize("bUseAsynLogin", bUseAsynLogin);
    serializer.serialize("wPort", wPort);
    serializer.serialize("sDeviceAddress", sDeviceAddress, 255);
    serializer.serialize("sUserName", sUserName, 255);
    serializer.serialize("sPassword", sPassword, 255);

}

shared_ptr< MultiMediaSourceMuxer> MMSM;
int  LoginUserID;
long lRealPlayHandle;
pthread_t GetStreamThread;
int   PlayHandle_Port;// m_iPlayHandle = -1;
bool  PlayHandle_bVideoSeted;// = false;
bool   PlayHandle_bAudioSeted;// = false;
std::shared_ptr<H264Encoder> PlayHandle_pH264Enc;
std::shared_ptr<AACEncoder> PlayHandle_pAacEnc;
std::shared_ptr<VideoInfo > PlayHandle_video;
std::shared_ptr<AudioInfo > PlayHandle_audio;
SmoothTicker PlayHandle_aTicker;
uint8_t  PlayHandle_adtsHeader;
int PlayHandle_dts;// = 0;
int PlayHandle_pts;// = 0;

};

Some fileds will not stored in the mysql.

### Read the data from mysql normally, but create the table will abort.

suisou commented 4 years ago

**_session s(p);

/// insert row

**s.flush();**

the app aborted the the flush fun._**

zussel commented 4 years ago

By now I don't support smart pointer like shared_ptr or unique_ptr. I'll reproduce your problem and try to estimate the effort to implement the feature.

zussel commented 4 years ago

Oh, I've just seen that you doesn't serialize the smart pointer, but the DWORD. Maybe that is the problem. I'll take a look.

suisou commented 4 years ago

Did you find the problem?

suisou commented 4 years ago

My op system is centos 8 64bit . Dword is unsigned long 64bit

zussel commented 4 years ago

Sorry for the late reply. I've just started to successfully reproduce the behavior. By I think it has somesthing to do with the quotation of the sql statement. Stay tuned...

zussel commented 4 years ago

Here's a working gist of my test code: https://gist.github.com/zussel/d31f2507320cdb67f737a20f95997a3a

At first try it doesn't worked. But my build libs didn't match the code. After rebuilding the lib. Everything works fine.

If you work on develop and build the lib yourself, be aware that on 2020/1/7 I've added a new SQL token "LIKE" which could lead to wrong behavior if you doesn't rebuild matador.

Please give the gist a try and tell me the result.

suisou commented 4 years ago

I have rebult the master and develp lib , then test it ,but the issue is same.

free(): invalid pointer

zussel commented 4 years ago

Ok, did you use the code from my gist? And which fields are not written to db?

suisou commented 4 years ago

s_mediaserverconf _conf; auto conf = s.insert(&_conf); conf.modify()->id = i; s.flush();

test it with these code ,but the issue is same .

suisou commented 4 years ago

matador::object_proxy::destroy(void * p) Line 372 C++ the fuction stacks . destroy pointer?

zussel commented 4 years ago

Which fields are not written to db?

suisou commented 4 years ago

All fields are written successfully.

zussel commented 4 years ago

I've set up a CentOS 8 VM 64bit and tried to reproduce this behavior - without success. Everthing worked fine.

The environment is:

Can you imagine any differences?

suisou commented 4 years ago

The environment same as mine. I think the the fields NOT serialized cause the issue. the gist code have remove the fields NOT serialized ,so it work normally. Do you test it with those fields ?

zussel commented 4 years ago

I've enhanced the gist with the not serialized fields and the code is still working. It must be something different.

Could you provide me the stacktrace of your attempt?

suisou commented 4 years ago

libc.so.6!raise libc.so.6!abort libc.so.6!__libc_message
libc.so.6!malloc_printerr
libc.so.6!_int_free matador::object_proxy::destroy(void p) Line 372 C++ libmatador-object.so.0!matador::object_proxy::~object_proxy()
libmatador-object.so.0!matador::prototype_node::clear(bool) libmatador-object.so.0!matador::object_store::remove_prototype_node(matador::prototype_node
, bool) libmatador-object.so.0!matador::object_store::clear(bool)
libmatador-object.so.0!matador::object_store::~object_store()
libmatador-orm.so.0!matador::persistence::~persistence()

zussel commented 4 years ago

I think without the possibility to debug, it's hard to find the problem.

Does the code work if you remove the not serialized fields? Did you use the gist?

How is the object inserted in your code?

zussel commented 4 years ago

As far as can't reproduce the behavior and there is no further information neither debug information, I'll close this issue.