Thread: Access Violation...

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733

    Post Access Violation...

    Not quite sure what to look at so I will simply hand the problem over to someone who better understands the file descriptor API.

    Code is all at https://github.com/awsdert
    Projects too look at are medit & Ipipe(dependency otherwise ignore)

    Files/Functions too look at are

    medit : guiMenu.c : guiOpen()
    medit : guiHacks.c : guiHacks_OnLoad()
    medit;ArmaxRaw : ArmaxRaw.c : armaxRawHack_RdLine() : Line 72 (Reached with debugger)
    medit;ArmaxRaw : ArmaxRaw.c : armaxRawHack_OnLoad() : Line 32 (Called the above)

    I'm running on Win7x64 using this data: medit.zip
    The .medit folder should be extracted to your user folder directly (haven't yet supported appdata folder).

    This is hobby project so any off topic suggested adaptations can be done if I find it suitable (steering clear of c++ though).

    Edit Going to church now so don't expect a quick reply

  2. #2
    Registered Superuser nul's Avatar
    Join Date
    Nov 2014
    Location
    Earth
    Posts
    53
    What is your problem?

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Title says it directly, gave you the description of the API I'm working with, thought that plus the code reference was enough to explain it.

    Anyways what I'm trying to do is load a plain text file into an application of mine (more in depth info at github), the file contains cheats for final fantasy 10 on the playstation 2 (but that's veering off topic slightly), the application first loads a hacklist format library (Action Replay Max Raw in this case), then when the user selects a file to load the file descriptor created by default by a more general function has a FILE* stream associated with it which is then passed onto the format library for it to do it's analysis on a produce a hacklist and some temporary files that represent the codelist for each hack found in the file (e.g. Infinite Money would have 1 write code whereas an All Characters \ Max Stats would have several loop codes), the reason for the temporary files is just for reducing in app memory usage.

    The problem is that when the library attempts to read the file I get an access violation and for the life of me I cannot see what is causing it.

    Edit: Shoulda mentioned in the first post I'm compiling as 32bit for now, not made any attempts to compile in 64bit yet.
    Last edited by awsdert; 01-25-2015 at 02:34 PM.

  4. #4
    Registered Superuser nul's Avatar
    Join Date
    Nov 2014
    Location
    Earth
    Posts
    53
    For future notice, posting a two-word, not-very-descriptive title with links to source code files saying you should look at these files/functions is not enough. Usually a code snippet is posted of the problem area, with the error/warning output from the compiler (at least). I don't have the time (nor the desire) to debug your entire project.

    That being said, I would read this How To Ask Questions The Smart Way before posting again. That section is particularly relevant here, but the whole thing is worth reading.

  5. #5
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Well if the debugger had given me more meaningful information I would've probably figured it out myself which is why I said at the beginning I was looking for someone familiar with the file descriptor API, that alone is already enough to tell you what sort of functions you're looking for which once looked at via the mentioned functions (which are the only relevant ones), that in turn gives you the call stack of relevance and an insight as to where problem occurs (hence line numbers on the last 2), that then gives an indication of what sort of possible problems might cause that which could be mentioned in a reply so I can re-examine my code and identify the problem with the help of the reply. Straight forward logic as far as I'm concerned, but if that's not enough then I'll post my debuggers output that I just run now:
    Code:
    #0 002C9FD4    ntdll!RtlIntegerToUnicodeString+0x2fc (??:??)
    #1 002C9FFC    ntdll!RtlIntegerToUnicodeString+0x20b (??:??)
    #2 002CA008    MSVCR120D!lock_file+0x58 (??:??)
    #3 002CA088    MSVCR120D!fgets+0x1c6 (??:??)
    #4 002CA09C    ArmaxRaw_msw_x86_d_vc!armaxRawHack_RdLine+0x24  (c:\users\lee\documents\github\medit\armaxraw.c:72)
    #5 002CB118    ArmaxRaw_msw_x86_d_vc!armaxRawHack_OnLoad+0x19e  (c:\users\lee\documents\github\medit\armaxraw.c:32)
    #6 002CC130    meditSmallGui_msw_x86_d_vc!guiHacks_OnLoad+0xc0  (c:\users\lee\documents\github\medit\guihacks\guihacks.c:564)
    #7 002CE15C    meditSmallGui_msw_x86_d_vc!guiOpen+0x34d  (c:\users\lee\documents\github\medit\guimenu.c:224)
    #8 002CE16C    meditSmallGui_msw_x86_d_vc!guiData_OnValueChanged+0x3c  (c:\users\lee\documents\github\medit\guimenu.c:235)
    #9 002CE178    iup!iupBaseCallValueChangedCb+0x51 (??:??)
    Code:
    Starting debugger: C:\p\dbgtools-x86\cdb.exe -G -lines -y C:/Users/lee/Documents/GitHub/medit/;C:/Users/lee/Documents/GitHub/; -srcpath C:/Users/lee/Documents/GitHub/medit/;C:/Users/lee/Documents/GitHub/; C:/p/bin/medit/meditSmallGui-msw-x86-d-vc.exe
    done
    Setting breakpoints
    (1c3c.1d70): Access violation - code c0000005 (first chance)
    Cannot open file: 
    At :0
    There is absolutely nothing more I can think of to give you.

  6. #6
    Registered Superuser nul's Avatar
    Join Date
    Nov 2014
    Location
    Earth
    Posts
    53
    Okay, now we have something to go on. Now I don't have any experience with this particular debugger, but it seems obvious from the new information that you are having an issuing opening a file. This could be due to one of many different reasons - file permissions, file is in use, depending on how you tried to open it, it could fail if the file doesn't exist.

    I suggest placing debug points around the nearest occurrence of trying to open a file, near the line that the debugger says the error occurred on, to narrow down exactly which file you're failing to load.

    Maybe someone more familiar with visual studio/cdb can provide more of an insight.

    Ways to improve your posts in the future:

    1. Include all relevant information and output from compilers/debuggers, including the name and version of each.
    2. Start off your post with a summary of the exact error(s) your dealing with, what you've tried so far to narrow down the issue, etc.

  7. #7

  8. #8
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Well can scratch narrowing down what file right off the bat since it's a controlled action, the library's onload function doesn't get called anywhere but a single instance where the app needs to know what hacks (cheats in this case) are in the file, the library deals with converting it to the apps unified memory format (soley for runtime use). The file in question was created by me via explorer and is a plain text file containing a list of raw armax cheats I created myself (bar the in battle codes), as far as I can see there should be zero access issues and the check for EOF is preventing read errors in this particular context so there should not be any issues there either. I would suggest taking a look at the functions, they're pretty small so shouldn't take too long 10 - 15 minutes tops I would reckon. Anyway I'm going to bed now, I'll probably lose my motivation again until Wednesday so don't expect a fast reply from now until then (also I work from 3pm to 9pm with about an hour allocated to travel - I leave at 1pm). For reference it's 12:30am where I am right now. Good night

  9. #9
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Quote Originally Posted by Jimmy View Post
    Unrealisticly difficult with this particular problem.

  10. #10
    Lurker
    Join Date
    Dec 2004
    Posts
    296
    Quote Originally Posted by awsdert View Post
    Unrealisticly difficult with this particular problem.
    No. You expect us to do all the work for you? You clearly have no experience using a technical forum. Try doing something like this in for example LKML...

    If you can't isolate the problem or show it with a small example, then you either have poorly constructed/designed code and/or you lack understanding of your own code.

    I'm helping people on this forum because I find it fun. Reading your crufty, buggy code and several 100 lines of it is not what I call fun. I'll pass.

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by awsdert View Post
    Unrealisticly difficult with this particular problem.
    Why are you using a user-mode debugger if you have the source code available to you on github? Don't you think this would be a whole lot easier if you just used a normal source-level debugging session?

    EDIT:
    Also, your file organization is a mess. You have the source on a GitHub folder in your documents, but the executable along with the debugger on a root folder named 'p'. Not saying anything about your naming conventions, but being the executable a GUI application, can it be that you are breaking its dependencies by moving it around? That's a c0000005 right there.
    Last edited by Mario F.; 01-25-2015 at 07:14 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    First p is just where I install all my apps to bypass the UAC and keep a single list of folders, 2nd user-mode debugger? I have codeblocks configured to use vc and cdb, I run the debugger from within codeblocks using it's big shiny red arrow (note the sarcasm), 3rd everything on github has thusfar been uploaded by me so pointless to download what I already have, finally the program is simply compiled to a directory in a directory pointed to by an environment variable (for consistency across platforms), 4th couple 100 lines? even if you put all the mentioned functions together it barely equates to 100 at worst, finally if you will not try to understand the context of the program you will never understand why it is difficult for me to reduce this problem down to your desired 5-10 lines which would not hold enough context.

    nul might have been a little rude at 1st but at least he was trying (and somewhat succeeding) to be helpful, jimmy and mario however, you're just being lazy and reminding me of a microsoft developer who was just as unhelpful at the start and only became helpful after he read though my comments more carefully. Additionally if it weren't for the complex requirements of this section of code I might have been able to reduce it down to a small functions worth.

  13. #13
    Lurker
    Join Date
    Dec 2004
    Posts
    296
    Quote Originally Posted by awsdert View Post
    First p is just where I install all my apps to bypass the UAC and keep a single list of folders, 2nd user-mode debugger? I have codeblocks configured to use vc and cdb, I run the debugger from within codeblocks using it's big shiny red arrow (note the sarcasm), 3rd everything on github has thusfar been uploaded by me so pointless to download what I already have, finally the program is simply compiled to a directory in a directory pointed to by an environment variable (for consistency across platforms), 4th couple 100 lines? even if you put all the mentioned functions together it barely equates to 100 at worst, finally if you will not try to understand the context of the program you will never understand why it is difficult for me to reduce this problem down to your desired 5-10 lines which would not hold enough context.

    nul might have been a little rude at 1st but at least he was trying (and somewhat succeeding) to be helpful, jimmy and mario however, you're just being lazy and reminding me of a microsoft developer who was just as unhelpful at the start and only became helpful after he read though my comments more carefully. Additionally if it weren't for the complex requirements of this section of code I might have been able to reduce it down to a small functions worth.
    Lol, you are the one that is rude and lazy and come here and expect the regulars, who help people on a daily basis, to do all the work. We don't want to look at your broken code, go away.

    I think you are coming close to the point where every regular might consider ignoring you forever, it will be a little hard to get any help then, huh?

  14. #14
    Registered Superuser nul's Avatar
    Join Date
    Nov 2014
    Location
    Earth
    Posts
    53
    Listen, buddy, our goal here is not to get our jollies by being snarky to people who need help, BUT, you have some issues and they are not confined to your code. You came in with a sense of arrogance and unreasonable expectations of the amount of work we would be willing to do for you.

    Okay, now the fact that you cannot narrow down your bug to a single function (at least) says that your code was not well written and/or you haven't done proper due diligence in hunting down your bug.

    I thought the output of the debugger looked odd, and as Mario F said, you aren't using a source-level debugger. I would recommend using MinGW | Minimalist GNU for Windows.

  15. #15
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Well the aim was to compile with vc binaries first but will MinGW provide me more info than what the vc binaries will? If so I will try it earlier than planned.
    As for me being lazy, I'm not lazy enough to not provide a smaller example if I can see a way of doing it.
    Rude? I only got rude after I noticed you guys being rude to me, tit for tat as far as I'm concerned.
    Poorly written code? Maybe but only in the naming of variables and perhaps inline structure, everything else is more down to how the app is supposed to work and is something I cannot get around.
    As for hunting down the bug, I would if only I could figure out what kind of access violation I'm getting, or was given a list of common access violations of which I could compare my own to to see if it is similar.
    Arrogance and Unreasonable Expectations? There was certainly no arrogance but the expectations may have been slightly off base on my part but I did try to give all the information I could think of, I figured anything else you needed you would ask for, and I thought for sure you would have figured out from that detailed post that I had not thought of a way to compress the problem into an example.
    Finally if cdb is not a source level debugger then what would you call a source level debugger? I'm a hobby coder so none of my C knowledge was learnt academically but via the internet references. Oh guess I should mention I'm using C99.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Access violation in C++
    By Sjvlsdsd in forum C++ Programming
    Replies: 3
    Last Post: 07-22-2011, 03:33 AM
  2. Access violation??
    By ozumsafa in forum C Programming
    Replies: 13
    Last Post: 09-18-2007, 10:11 AM
  3. Why am I having an access violation?
    By ldb88 in forum C++ Programming
    Replies: 12
    Last Post: 06-12-2007, 12:27 PM
  4. Access Violation!!
    By Yoshi in forum C++ Programming
    Replies: 4
    Last Post: 09-11-2002, 01:22 PM

Tags for this Thread