Note that there are some explanatory texts on larger screens.

plurals
  1. POcould stl set::insert cause BSOD?
    primarykey
    data
    text
    <p>I have written a 'filemon' utility which basically logs file being opened during a period of time. Now I have exact these two functions in my 'filemon' utility:</p> <pre><code>set&lt;wstring&gt; wstrSet; // callback - get notified by callback filter driver on any file open operation void CbFltOpenFileN( CallbackFilter* Sender, LPWSTR FileName, ACCESS_MASK DesiredAccess, WORD FileAttributes, WORD ShareMode, DWORD CreateOptions, WORD CreateDisposition ) { // don't log for directories if (FileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY) { return; } wstring wstr = FileName; wstr.append(L"\n"); //wstrSet.insert(wstr); // as soon as I un-comment this line I start getting BSOD in multiple execution of this utility } // Read all paths stored in the set and write them into the log file void WritePathsToLog() { typedef set&lt;wstring&gt;::const_iterator CI; printf("\nNo. of files touched ===&gt; %d\n\n", wstrSet.size()); for (CI iter = wstrSet.begin(); iter != wstrSet.end(); iter++) { fputws((*iter).c_str(), logFile); } } </code></pre> <p>Basically what this code does is that 'filemon' utility interacts with callback filter driver and whenever file is touched by any process the driver reports the respective filename to the 'filemon' utility via CbFltOpenFileN function.</p> <p>Now the issue is that this 'filemon' utility runs fine on win7 x64 machine 4GB machine but as soon as I uncomment the last line in the CbFltOpenFileN function i.e. start inserting the reported filename in the set then I start getting BSOD mostly with BugCheck 0xCC and sometimes with BugCheck 0x50 which basically indicates that "system is trying to access already freed memory"</p> <p>P.S. on win7 x64 with 8GB RAM I am not seeing any issue at all irrespective of whether last line in the CbFltOpenFileN function is commented or not.</p> <p>Currently, 'wstrSet' is using default allocator so do I need to use a specific allocator while declaring set wstrSet; if yes can someone tell me how &amp; why? </p> <ul> <li>Let me share some more information here: <ul> <li>I am using VS2010</li> <li>My utility is a 32 bit application targeted for x86 platform</li> <li>The fileystem filter driver I am using is callabck filter driver provided by Eldos corp.</li> <li>Now I am tetsing this utility using a simulator which generates lots of files and then starts the 'filemon' utility, then it touches all those files and at the end stops the 'filemon' utility. This simulator repeates this process 25 times.</li> <li>Now for case where last line is commented I get empty log file created 25 times as I don't insert anything in set but 'filemon' utility also doesn't causes any BSOD</li> <li>But for case where last line is NOT commented I get log file created each time with path enteries as now I am inserting paths in the set but then during first few iteration, say 2nd or 3rd or 6th, itself 'filemon' utility hits this BSOD scenario.</li> </ul></li> </ul> <p>It's hard for me to repro this issue in debug mode as my simulator take cares of the start/stop of 'filemon' utility and i need to run it multiple time to repro the issue.</p> <p>Hope this added info helps!!!</p> <p>Thanks and Regards, Sachin</p>
    singulars
    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