Prev: Listener to HG callback
Next: Double to char
From: Nilesh on 28 Jun 2010 04:38 Hello , I am working on mex files as i want to store the results of matlab simulations to a database. the databse i already defined .The C++ program is working fine and correct , but when i try to write the mex file in matlab ..it compiles andlinks properly but at the end of the program it crashes saying segmentation fault.i am in total loss here .please help me. #include "mex.h" #include <iostream> #include <pqxx/pqxx> #include "pqxx/connection_base" #include "pqxx/connection" #include "pqxx/transaction_base" #include "pqxx/result" #include <string> #include "matrix.h" using namespace std; using namespace pqxx; void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) { int k; mexPrintf("Hello, world!\n"); connection C("hostaddr=134.91.99.228 dbname=results user=results password=results"); mexPrintf("%s",C.dbname()); k = C.is_open() ; mexPrintf("%s %d","PROB",k); mexPrintf("%s","Hello world"); C.disconnect(); k =C.is_open(); mexPrintf("%s %d","PROB",k); } // gets executed untill here and then crashes. Please helpme .here C is and conenction object to the class connection.I dont know where i am going wrong and i think mostly its problem of memory allo0cation and freeing it. Thanks in advance. NILESH JAVAR
From: Steven Lord on 28 Jun 2010 09:43 "Nilesh " <nileshjavar(a)gmail.com> wrote in message news:i09n1d$6th$1(a)fred.mathworks.com... > Hello , > > I am working on mex files as i want to store the results of matlab > simulations to a database. the databse i already defined .The C++ program > is working fine and correct , but when i try to write the mex file in > matlab ..it compiles andlinks properly but at the end of the program it > crashes saying segmentation fault.i am in total loss here .please help me. I don't know if anyone will be able to help you debug this, as it probably depends on what the "connection" object is doing. I think you'll need to follow the steps given in sections 21 through 24 of this document: http://www.mathworks.com/support/tech-notes/1600/1605.html *snip* > connection C("hostaddr=*snip* dbname=*snip* user=*snip* > password=*snip*"); I hope that you used a dummy address and/or dummy information about the database when you posted. > mexPrintf("%s",C.dbname()); > k = C.is_open() ; > mexPrintf("%s %d","PROB",k); > mexPrintf("%s","Hello world"); C.disconnect(); > k =C.is_open(); > mexPrintf("%s %d","PROB",k); > } // gets executed untill here and then crashes. > > Please helpme .here C is and conenction object to the class connection.I > dont know where i am going wrong and i think mostly its problem of memory > allo0cation and freeing it. That's entirely possible; but again, if the segmentation fault is coming about due to memory issues in the connection object, I don't think anyone here will be able to help you debug. You may need to talk to whomever wrote the connection object class for help in debugging. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Nilesh on 29 Jun 2010 03:22 "Steven Lord" <slord(a)mathworks.com> wrote in message <i0a8t2$gce$1(a)fred.mathworks.com>... > > "Nilesh " <nileshjavar(a)gmail.com> wrote in message > news:i09n1d$6th$1(a)fred.mathworks.com... > > Hello , > > > > I am working on mex files as i want to store the results of matlab > > simulations to a database. the databse i already defined .The C++ program > > is working fine and correct , but when i try to write the mex file in > > matlab ..it compiles andlinks properly but at the end of the program it > > crashes saying segmentation fault.i am in total loss here .please help me. > > I don't know if anyone will be able to help you debug this, as it probably > depends on what the "connection" object is doing. I think you'll need to > follow the steps given in sections 21 through 24 of this document: > > http://www.mathworks.com/support/tech-notes/1600/1605.html > > *snip* > > > connection C("hostaddr=*snip* dbname=*snip* user=*snip* > > password=*snip*"); > > I hope that you used a dummy address and/or dummy information about the > database when you posted. > > > mexPrintf("%s",C.dbname()); > > k = C.is_open() ; > > mexPrintf("%s %d","PROB",k); > > mexPrintf("%s","Hello world"); C.disconnect(); > > k =C.is_open(); > > mexPrintf("%s %d","PROB",k); > > } // gets executed untill here and then crashes. > > > > Please helpme .here C is and conenction object to the class connection.I > > dont know where i am going wrong and i think mostly its problem of memory > > allo0cation and freeing it. > > That's entirely possible; but again, if the segmentation fault is coming > about due to memory issues in the connection object, I don't think anyone > here will be able to help you debug. You may need to talk to whomever wrote > the connection object class for help in debugging. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com > Yes ,it would have been better if would ask the person who wrote the class ..but it the above programs c++ vesion 100% fine visual studio 2010 or 2008.but when it try to convert it to mex file the problems are araising.In ´C++ code there is no need to allocate memory .it just works 5n without allocating the memory as i use static libraries .but if use static libraries in matlad it isleading to many unresolved symbols.so i used dynamic.but when i am using it(dynamic) in matlab its leading to segmentation fault in the end. Thanks, NILESH.
From: Steven Lord on 29 Jun 2010 09:50 "Nilesh " <nileshjavar(a)gmail.com> wrote in message news:i0c6v1$el0$1(a)fred.mathworks.com... > "Steven Lord" <slord(a)mathworks.com> wrote in message > <i0a8t2$gce$1(a)fred.mathworks.com>... *snip* > Yes ,it would have been better if would ask the person who wrote the > class ..but it the above programs c++ vesion 100% fine visual studio 2010 > or 2008.but when it try to convert it to mex file the problems are > araising. That doesn't rule out the problem being in the connection object -- Visual Studio may not be exercising the object in such a way that the conditions that triggers the segmentation violation are satisfied. > In �C++ code there is no need to allocate memory .it just works 5n without > allocating the memory as i use static libraries .but if use static > libraries in matlad it isleading to many unresolved symbols.so i used > dynamic.but when i am using it(dynamic) in matlab its leading to > segmentation fault in the end. Post the first few lines (say 5-10) of the segmentation fault log that start with [0], [1], etc. If the top couple of those refer to the connection library then I reiterate my suggestion to contact the author of the connection library or whomever is responsible for its maintenance for help in diagnosis. Or, to put it another way -- comment out every reference to the connection object in your MEX-file, compile it, and run it several times. If it doesn't crash, then _something_ relating to how the connection object interacts with the MEX-file environment is probably causing the crash. Whatever it is, the connection object is the first place I'd investigate. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Nilesh on 30 Jun 2010 03:44 "Steven Lord" <slord(a)mathworks.com> wrote in message <i0ctm6$j8o$1(a)fred.mathworks.com>... > > "Nilesh " <nileshjavar(a)gmail.com> wrote in message > news:i0c6v1$el0$1(a)fred.mathworks.com... > > "Steven Lord" <slord(a)mathworks.com> wrote in message > > <i0a8t2$gce$1(a)fred.mathworks.com>... > > *snip* > > > Yes ,it would have been better if would ask the person who wrote the > > class ..but it the above programs c++ vesion 100% fine visual studio 2010 > > or 2008.but when it try to convert it to mex file the problems are > > araising. > > That doesn't rule out the problem being in the connection object -- Visual > Studio may not be exercising the object in such a way that the conditions > that triggers the segmentation violation are satisfied. > > > In C++ code there is no need to allocate memory .it just works 5n without > > allocating the memory as i use static libraries .but if use static > > libraries in matlad it isleading to many unresolved symbols.so i used > > dynamic.but when i am using it(dynamic) in matlab its leading to > > segmentation fault in the end. > > Post the first few lines (say 5-10) of the segmentation fault log that start > with [0], [1], etc. If the top couple of those refer to the connection > library then I reiterate my suggestion to contact the author of the > connection library or whomever is responsible for its maintenance for help > in diagnosis. > > Or, to put it another way -- comment out every reference to the connection > object in your MEX-file, compile it, and run it several times. If it > doesn't crash, then _something_ relating to how the connection object > interacts with the MEX-file environment is probably causing the crash. > Whatever it is, the connection object is the first place I'd investigate. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com > Theses are the first few lines of the segmentation fault : Configuration: MATLAB Version: 7.8.0.347 (R2009a) MATLAB License: 245836 Operating System: Microsoft Windows Server Longhorn Window System: Version 6.0 (Build 6002: Service Pack 2) Processor ID: x86 Family 6 Model 7 Stepping 6, GenuineIntel Virtual Machine: Java 1.6.0_04-b12 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode Default Encoding: windows-1252 Fault Count: 1 Register State: EAX = 0000008a EBX = 04317fe0 ECX = 04430000 EDX = 04317fe0 ESI = 38c582c5 EDI = 04317fd8 EBP = 00c2e0ac ESP = 00c2e078 EIP = 77696739 FLG = 00010206 Stack Trace: [0] ntdll.dll:0x77696739(0x04317fe0, 0x1e321638, 0, 0x00c2e0d4 " áÂ") [1] ntdll.dll:0x776966ea(0x04430000, 0, 0x04317fd8, 0x00c2e120 "0áÂ") [2] kernel32.dll:0x76d49a26(0x04430000, 0, 0x04317fe0, 0xe4c3440c) [3] MSVCR90.dll:0x6cec3c1b(0x04317fe0, 0x00c2e201, 0x00c2e158 "táÂ", 0x04122764) [4] connection1.mexw32:0x04122c70(0x04317fe0, 1, 0x00c2e200, 0x04317fe0) [5] connection1.mexw32:0x04122764(0xe4c33bcb, 0x00c2e200, 0x00c2e190 "hâÂ", 0x0412c4d8) [6] connection1.mexw32:0x04122305(0x00c2e200, 0x00c2e19c "ÀáÂ", 0x041220f8, 0xe4c33b23) [7] connection1.mexw32:0x041221af(0xe4c33b23, 0x00c2e1d0, 0x00c2e268, 0x0412c441) [8] connection1.mexw32:0x041220f8(0x043581b0, 0x00c2e1d0, 0, 0x00c2e1a0) [9] connection1.mexw32:0x04121f14(0xe4c338cb, 0, 0, 0x00c2e23c "`þÉh") [10] connection1.mexw32:0x04121c28(0, 0x00c2e990, 0, 0x00c2e900) [11] libmex.dll:_mexRunMexFile(0, 0x00c2e990, 0, 0x00c2e900) + 132 bytes [12] libmex.dll:private: void __thiscall Mfh_mex::runMexFileWithSignalProtection(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00c2e990, 0, 0x00c2e900) + 73 bytes [13] libmex.dll:public: virtual void __thiscall Mfh_mex::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00c2e990, 0, 0x00c2e900) + 321 bytes [14] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00c2e990, 0, 0x00c2e900) + 204 bytes [15] m_interpreter.dll:public: void __thiscall ResolverFunctionDesc::CallFunction(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const)(0, 0x00c2e990, 0, 0x00c2f0fc "ÈóÂ") + 81 bytes
|
Pages: 1 Prev: Listener to HG callback Next: Double to char |