Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ memory access violation mysteriously goes away if I add one dummy argument to class constructor
    primarykey
    data
    text
    <p>So, lately I've been banging my head on this runtime error I get running this code. This is a client/server application with the client being a DLL injected into another process address space and the server a classical standalone program. This is the incriminated bit of code (I've removed non-relevant parts of the file):</p> <pre><code>#include "TableInfo.h" TableInfo::TableInfo(tstring id) { this-&gt;id = id; } TableInfo::TableInfo(int num, tstring id) { //this-&gt;num = num; this-&gt;id = id; } void TableInfo::dump() { //tcout &lt;&lt; "num = " &lt;&lt; this-&gt;num &lt;&lt; endl; tcout &lt;&lt; "id = " &lt;&lt; this-&gt;id &lt;&lt; endl; } </code></pre> <p>As you can see I've got two constructors but they are pratically the same except for the signature. <code>TableInfo</code> should contains some information that will be later embedded in another object which I'm trying to send from the client to the server over a TPC socket. This is how I do it:</p> <pre><code>TableInfo tt(999, L"MEGAOHM"); // WORKS! //TableInfo tt(L"MEGAHOM2"); // DOESN'T WORK! IpcRequest rr(CBE_NEW_TABLE); rr.setTableInfo(tt); c.sendRq(rr); </code></pre> <p>So, the <code>IpcRequest</code> class is just another class containing one instance of <code>TableInfo</code> and some other variables and it will get sent over to the server. The <code>sendRq</code> function sends the entire object to the server where I try to display the data contained in it. As you can see from the code if I call the 2 arguments constructor it work otherwise I get a memory access violation error. According the to debugger the error occurs in the <code>dump</code> function inside <code>TableInfo</code> when I try to access the id field. I really don't know what this could be related to, of course I can still use a constructor with 2 ore more arguments and the problem disappears but I'd like to know how is this possible.</p> <p>PS: <code>tstring</code> is just a macro I defined which resolves to wstring or string depending on the UNICODE settings.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload