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

Author Topic: Access violation executing location 0x0000000000000000.  (Read 8667 times)

0 Members and 1 Guest are viewing this topic.

Fyuchanick

  • Newbie
  • *
  • Posts: 8
    • View Profile
Access violation executing location 0x0000000000000000.
« on: August 29, 2018, 06:21:31 pm »
So when I try to play sound using soundBuffer, my game crashes. When I use visual studio's debugger, it gives me this exception:

Exception thrown at 0x0000000000000000 in SFML_Project1.exe: 0xC0000005: Access violation executing location 0x0000000000000000.

I have all the project settings done correctly and have copied the correct files into the correct folder, and there are no syntax errors or runtime errors. Not only that but I also ended up working on this on a different computer for personal reasons (copied using sourcetree + git), and the program runs fine on that computer. I have all my drivers up to date as well. So why does it give me this exception?

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Access violation executing location 0x0000000000000000.
« Reply #1 on: August 29, 2018, 07:04:43 pm »
Do you have a minimal example that causes this?
Back to C++ gamedev with SFML in May 2023

Fyuchanick

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Access violation executing location 0x0000000000000000.
« Reply #2 on: August 29, 2018, 07:11:04 pm »
What do you mean by minimal example?

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Access violation executing location 0x0000000000000000.
« Reply #3 on: August 29, 2018, 07:15:55 pm »
Back to C++ gamedev with SFML in May 2023

Fyuchanick

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Access violation executing location 0x0000000000000000.
« Reply #4 on: August 29, 2018, 08:26:26 pm »
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <math.h>
#include <random>
#include <iterator>
using namespace std;
Particle::Particle(string soundEffect) {
   sprite = sf::CircleShape(5.f);
   //positionIterator = 0;
   positions = {};
   movements = {};
   animationPreviousTime = 0;
   durationPreviousTime = 0;
   currentTime = 0;
   animationDelay = 0.01;
   buffer.loadFromFile(soundEffect);
   sound.setBuffer(buffer);
}
void Particle::activate(int startX, int startY, sf::Color color, int amount, float newDuration) {
   if (positions.size() < 100) {
      sprite.setFillColor(color);
      duration = newDuration;
      sound.setBuffer(buffer);
      sound.play();
      createPositions(startX, startY, amount);
      durationPreviousTime = gameClock.getElapsedTime().asSeconds();
   }
}

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Access violation executing location 0x0000000000000000.
« Reply #5 on: August 31, 2018, 02:43:56 pm »
That's not a minimal example. I can't take that code and compile it.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Fyuchanick

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Access violation executing location 0x0000000000000000.
« Reply #6 on: August 31, 2018, 04:33:21 pm »
That's not a minimal example. I can't take that code and compile it.

I don't see why you need to compile it.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Access violation executing location 0x0000000000000000.
« Reply #7 on: August 31, 2018, 05:36:28 pm »
Did you read the link FRex posted? It describes what a minimal example should be and why.

From the posted code, I can't tell you what's wrong. If had created a minimal examples that I can compile and reproduce the issue locally on my machine, I'd be able to tell you what's wrong with the code and even better, chances are, you'd notice your mistake on your own while creating the minimal example.

0x0000000 etc means you're most likely trying to dereference a null pointer somewhere.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Fyuchanick

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Access violation executing location 0x0000000000000000.
« Reply #8 on: September 01, 2018, 02:21:20 pm »
Did you read the link FRex posted? It describes what a minimal example should be and why.

From the posted code, I can't tell you what's wrong. If had created a minimal examples that I can compile and reproduce the issue locally on my machine, I'd be able to tell you what's wrong with the code and even better, chances are, you'd notice your mistake on your own while creating the minimal example.

0x0000000 etc means you're most likely trying to dereference a null pointer somewhere.

I read the link. It only talked about "maybe you would spot the error yourself." I've written my code in a way that I understand it well enough. I'm not trying to use any pointers in that case, just use soundBuffer. I can maybe see why you might be able to figure something out by running the compiled exe on your computer, but I don't see it as worth the effort of me rewriting my code all over again.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Access violation executing location 0x0000000000000000.
« Reply #9 on: September 07, 2018, 05:27:50 pm »
"Minimal and complete code" is not only so you can spot the mistake in the code but also so that there is something with which others can work. If you have a minimal code that still has the problem and still don't know what's wrong, others can help but not having a minimal code means others are unlikely to be able to help due to others not being able to "understand it well enough" like you can.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Fyuchanick

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Access violation executing location 0x0000000000000000.
« Reply #10 on: September 08, 2018, 02:26:32 pm »
I don't see how my code is not minimal. It is not complete enough to compile, but that would require virtually rewriting it. There are two functions that have the error, which are part of a class which defines the variables, an instance of the class is defined in main, and the functions are run as part of the game loop in main, all of which functions correctly except for the code inside of the functions.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Access violation executing location 0x0000000000000000.
« Reply #11 on: September 10, 2018, 02:02:41 pm »
Having a minimal compilable example can help you reduce the scope where the problem is and find the root cause. It's not only helping us, but also helping you. With that code, there is nothing we can say. If you cannot abide by this simple rule, I do not think we can help you. Help us help you.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord