Intro Download and install Frequently Asked Questions Tips and tricks

Homepage







© J.C. Kessels 2009
MyDefrag Forum
June 19, 2013, 02:40:26 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: memory problem in swprintf_s  (Read 4849 times)
blackt1ger
JkDefrag Junior
**
Posts: 7


View Profile
« on: May 20, 2007, 05:26:11 pm »

The buffer refers to the count of characters, not the size of memory (as opposed to the non-obvious name 'sizeOfBuffer', which is incorrect).

I kept getting exceptions in DevStudio 2005 in debug builds on the "free".

Great program.  

-p.s.  I haven't yet checked the x64 build yet.
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7156



View Profile WWW
« Reply #1 on: May 20, 2007, 07:45:18 pm »

Thank you very much for the info, but where exactly in the sources did you find this problem?
Logged
blackt1ger
JkDefrag Junior
**
Posts: 7


View Profile
« Reply #2 on: May 21, 2007, 09:10:36 am »

Quote from: "jeroen"
Thank you very much for the info, but where exactly in the sources did you find this problem?


common2.h: 1767, 1791, 1911, 2024, 3243, 3500.  

I hate the "safe string stuff".  Just another number to get worry about.

Oh, I get a bunch of other diagnostics..... Most related to unchecked 'malloc's.  Although in my humble opinion, when malloc starts to fail, everything else will too.  FYI:  Here's the complete dump - generated from 'Code Analysis' in Devstudio.

As you can see, I'm doing a C++/CLI version.  It's complete, but I've got a lot of testing still to do.

----------------------------------------------------------------------------
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(615) : warning C6262: Function uses '17096' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(707) : warning C6011: Dereferencing NULL pointer 'NewFragment': Lines: 616, 617, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 638, 639, 647, 648, 649, 650, 651, 656, 657, 665, 669, 673, 674, 676, 679, 681, 685, 687, 693, 695, 701, 706, 707
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(730) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'sprintf_s': Lines: 616, 617, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 638, 639, 647, 648, 649, 650, 651, 656, 657, 665, 669, 673, 674, 676, 679, 681, 725, 726, 728, 729, 730
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(905) : warning C6262: Function uses '65616' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(1043) : warning C6262: Function uses '33936' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(1793) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'swprintf_s': Lines: 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1732, 1733, 1734, 1737, 1738, 1739, 1740, 1741, 1746, 1747, 1752, 1753, 1754, 1758, 1764, 1767, 1768, 1769, 1770, 1772, 1773, 1776, 1777, 1778, 1782, 1789, 1800, 1801, 1805, 1806, 1807, 1813, 1814, 1815, 1816, 1821, 1824, 1829, 1830, 1891, 1752, 1753, 1754, 1758, 1764, 1767, 1768, 1769, 1770, 1772, 1773, 1776, 1777, 1778, 1782, 1789, 1800, 1801, 1805, 1806, 1807, 1813, 1814, 1815, 1816, 1821, 1824, 1829, 1830, 1891, 1752, 1753, 1754, 1758, 1764, 1767, 1768, 1769, 1770, 1772, 1773, 1774, 1776, 1777, 1778, 1782, 1789, 1790, 1791, 1792, 1793
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(1913) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'swprintf_s': Lines: 1902, 1903, 1904, 1905, 1906, 1909, 1910, 1911, 1912, 1913
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(2026) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'swprintf_s': Lines: 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1973, 1974, 1975, 1974, 1975, 1974, 1975, 1974, 1999, 2000, 2001, 2002, 2003, 2007, 2008, 2015, 2019, 2024, 2025, 2026
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(2027) : warning C6387: 'argument 2' might be '0': this does not adhere to the specification for the function '_wcsicmp': Lines: 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1973, 1974, 1975, 1974, 1975, 1974, 1975, 1974, 1999, 2000, 2001, 2002, 2003, 2007, 2008, 2015, 2019, 2024, 2025, 2026, 2027
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(2001) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'wcscpy_s': Lines: 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1973, 1974, 1975, 1974, 1975, 1974, 1975, 1974, 1999, 2000, 2001
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(2027) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function '_wcsicmp': Lines: 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1973, 1974, 1975, 1974, 1975, 1974, 1975, 1974, 1999, 2000, 2001, 2002, 2003, 2007, 2008, 2015, 2019, 2024, 2025, 2026, 2027
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(2994) : warning C6262: Function uses '32848' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(3249) : warning C6202: Buffer overrun for 'Data.VolumeName', which is possibly stack allocated, in call to 'GetVolumeNameForVolumeMountPointW': length '520' exceeds buffer size '102'
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(3249) : warning C6386: Buffer overrun: accessing 'argument 2', the writable size is '102' bytes, but '520' bytes might be written: Lines: 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3141, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3200, 3216, 3228, 3229, 3230, 3233, 3234, 3238, 3239, 3243, 3244, 3245, 3249
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(3245) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'swprintf_s': Lines: 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3141, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3154, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3200, 3216, 3228, 3229, 3230, 3233, 3234, 3238, 3239, 3243, 3244, 3245
d:\jkdefrag-src-3.8\jkdefragcli\common2.h(3502) : warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'swprintf_s': Lines: 3409, 3410, 3411, 3412, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3424, 3427, 3428, 3432, 3433, 3442, 3443, 3451, 3452, 3462, 3463, 3464, 3468, 3470, 3477, 3484, 3487, 3497, 3498, 3500, 3501, 3502
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7156



View Profile WWW
« Reply #3 on: May 22, 2007, 09:21:34 am »

Thank you very much for the info, I appreciate it! I will look at the sources and make the necessary corrections. Thanks again!
Logged
blackt1ger
JkDefrag Junior
**
Posts: 7


View Profile
« Reply #4 on: May 23, 2007, 08:24:31 am »

Maybe we ought to take this offline.....

I'm working through the MatchMask and getting access violations.  Just started on this today.

FYI:  The C++/CLI wrapper is almost done.  Of course, there's a full blown GUI.  Better than Diskeeper, I think, as it stops being a gui for extremely large harddrives.

If you want to send me an email to contact you regarding this.  You can contact me at my registered email.

Take care,

--Ken
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7156



View Profile WWW
« Reply #5 on: May 23, 2007, 10:04:12 am »

Quote from: "blackt1ger"
I'm working through the MatchMask and getting access violations.

Huh? I think that function can only generate access violations if it's given bad input, so I wonder what is going on there... Perhaps a near/far linker problem?

Quote from: "blackt1ger"
The C++/CLI wrapper is almost done.

Thanks for the offer, I appreciate it! I tried myself to make JkDefrag into a class (very recently), but I have found it makes everything very complicated. OOP is a very useful programming technique, but should only be used when it simplifies things. So I dropped it and went back to flat C code.
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7156



View Profile WWW
« Reply #6 on: May 23, 2007, 06:49:16 pm »

Quote from: "blackt1ger"
'Code Analysis' in Devstudio.

I have looked around but I cannot find anything that is called "Code Analysis" in my Visual Studio 2005 Professional Edition. Where can I find it? Perhaps it's only included in other versions?
Logged
blackt1ger
JkDefrag Junior
**
Posts: 7


View Profile
« Reply #7 on: May 26, 2007, 01:57:02 pm »

Quote from: "jeroen"
Quote from: "blackt1ger"
'Code Analysis' in Devstudio.

I have looked around but I cannot find anything that is called "Code Analysis" in my Visual Studio 2005 Professional Edition. Where can I find it? Perhaps it's only included in other versions?


Yes, probably not.  I have the Team Studio for Software Developer Edition.  As well as DevPartner Studio Professional (additional analysis, etc).  Which is why I sent the full logs to you.....  

[in project settings, under configuration properties, it shows up right after the "Custom Build Step" node and before the "Web Deployment" node]

I hope to put the C++/CLI version up on www.gotdotnet.com this week.
And I hope to put the app up on my website a little later on, once I finalize my website.  I'm trying to decide whether to make the code to the app available, as it uses Developer's Express controls and requires a purchased licence.  Even though it is helpful to see the code, I don't want to be bugged by people complaining that it won't compile (and it probably won't).

The C++/CLI stuff actually doesn't add much overhead.  The GUI does, though.  I'm running the defragger in it's own thread, and the Callback's are fired as events and must be invoked crossthread to communicate with the GUI.  Hence, I added a "SyncObject".  When set, all calls are invoked on the thread running the "SyncObject" (a control).  The analyze just goes way too fast to even attempt to update the GUI, but everything is fine.  The debug callback NEVER invokes on the thread, as it is primarily intended for logs.  

I set up a Trace listener, so that alll debug callbacks go straight to the tracing system, which is extensible via app.config.    I want to finish the "code comments" and attributes.  I was also thinking of turning the whole thing into a component so that it can be added onto the design surface.

In general the C++/CLI just implements the callback code and refires it as an event.
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7156



View Profile WWW
« Reply #8 on: June 02, 2007, 03:55:51 pm »

I have just released JkDefrag v3.9. The warnings you have listed should now all be gone, but maybe there are new warnings? There have been many changes in the code....
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!