Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Access violation reading area with :setBuffer (SFML 2)  (Read 7626 times)

0 Members and 2 Guests are viewing this topic.

WiltedChameleon

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Access violation reading area with :setBuffer (SFML 2)
« on: July 27, 2012, 02:01:20 am »
I have this code:

                m_soundintrobuffer.loadFromFile(DataLoader::getSoundPath(1));
                m_soundintroplayer.setBuffer(m_soundintrobuffer);

The file is certainly loading correctly as it gives no console output relating to file loading, and when I comment out the second line the program runs fine.

However the second line is resulting in me getting this output:

First-chance exception at 0x7434364E (sfml-audio-2.dll) in Viscus Engine.exe: 0xC0000005: Access violation reading location 0x3F800011.

Unhandled exception at 0x7434364E (sfml-audio-2.dll) in Viscus Engine.exe: 0xC0000005: Access violation reading location 0x3F800011.

If it helps, after this my IDE (Visual Studio 2012 RC) brings up the file 'free.c' which contains:


/***
*free.c - free an entry in the heap
*
*       Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
*       Defines the following functions:
*           free()     - free a memory block in the heap
*
*******************************************************************************/


#include <cruntime.h>
#include <malloc.h>
#include <winheap.h>
#include <windows.h>
#include <internal.h>
#include <mtdll.h>
#include <dbgint.h>
#include <rtcsup.h>

/***
*void free(pblock) - free a block in the heap
*
*Purpose:
*       Free a memory block in the heap.
*
*       Special ANSI Requirements:
*
*       (1) free(NULL) is benign.
*
*Entry:
*       void *pblock - pointer to a memory block in the heap
*
*Return:
*       <void>
*
*******************************************************************************/


void __cdecl _free_base (void * pBlock)
{

        int retval = 0;


        if (pBlock == NULL)
            return;

        RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));

        retval = HeapFree(_crtheap, 0, pBlock); // <<<< It seems to be dying here
        if (retval == 0)
        {
            errno = _get_errno_from_oserr(GetLastError());
        }
}


64-bit windows 7, Visual Studio 2012 RC, compiling as multithreaded (non-dll) to avoid end users needing redistributables, non-static SFML, all DLLs for SFML, OpenAL and libsnd-file1 or whatever are present.

Sorry if this is some stupid mistake I've made. I hope not. :P

Also the types are right otherwise it'd presumably stop compiling rather than at runtime.

WiltedChameleon

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Access violation reading area with :setBuffer (SFML 2)
« Reply #1 on: July 28, 2012, 02:22:46 am »
And also, merely having this line in a class:

sf::SoundBuffer m_soundintrobuffer;

Makes it say:

Unhandled exception at 0x7653A4B9 (ole32.dll) in Viscus Engine.exe: 0xC0000005: Access violation reading location 0xFEEEFEEE.

When I close the program. I'm not even loading anything into the variable, just having it existent. Nothing is ever done to that variable on my side of it, since I commented out both of the lines to load and play a while ago.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Access violation reading area with :setBuffer (SFML 2)
« Reply #2 on: July 28, 2012, 02:32:50 am »
You should make use of the debugger and if you're not familiar with it learn it, its the most usefull tool for programmers, not knowing how to use it, is like not having a license for driving a car. ;)

When your application crashes and you land automagically in the debug mode, there's a window in Visual Studio that lets you see the backtrack (usually bottom right) which shows you exactly how you got to the error in the free.c file.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

WiltedChameleon

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Access violation reading area with :setBuffer (SFML 2)
« Reply #3 on: July 30, 2012, 10:59:25 am »
I'm guessing you mean the call stack? I'd sort of ignored it since it only pointed me to that line of code, and a bunch of disassembly from some random windows DLL thing, but upon you reminding me of it I looked again and figured that if a DLL is causing it that isn't from SFML it might actually be that.

It turns out that one of the DLLs, I'm guessing it's "ntdll.dll" does not particularly like SFML and throws some exception.

Providing I hadn't done something to mess it up, here's the solution for future viewers:



Change the platform toolset to v100. I'm figuring this is sort of like a compatibility mode that compiles it as if it was VS2010, but I can't say that for certain.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Access violation reading area with :setBuffer (SFML 2)
« Reply #4 on: July 30, 2012, 12:01:31 pm »
The clean solution would be to recompile SFML.

When Visual C++11 (VS 2012) will be officially out, there will be a precompiled release of SFML for it.
Laurent Gomila - SFML developer

WiltedChameleon

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Access violation reading area with :setBuffer (SFML 2)
« Reply #5 on: July 30, 2012, 12:32:46 pm »
The clean solution would be to recompile SFML.

When Visual C++11 (VS 2012) will be officially out, there will be a precompiled release of SFML for it.

I suppose I also get the extra advantage of having a lot more compatibility if I switch to /MDD for runtime libraries this way though.

 

anything