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

Author Topic: Text::SetString() raises exception  (Read 3205 times)

0 Members and 2 Guests are viewing this topic.

Beta_Ravener

  • Jr. Member
  • **
  • Posts: 51
    • ICQ Messenger - 271426715
    • View Profile
Text::SetString() raises exception
« on: August 06, 2011, 01:11:59 pm »
Hello there. I recently ran into problem I can't solve. Anywhere I call Text::SetString() my program raises an exception. MSVC points me to strlen.asm file at line with arrow
Code: [Select]
  str_misaligned:
   ; simple byte loop until string is aligned
-> mov     al,byte ptr [ecx]


and give me "0xC0000005: Access violation reading location". That error should be pointer related, but I don't work with pointers anywhere arround where this error appears. It's quite strange because MSVC doesn't even enter debug mode(checkpoint at first line of main), it's enough to see that I call SetString somewhere.. I haven't met with such thing before so I'd be glad for some help. I'm using recent SFML 2.0 build.

P@u1

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Text::SetString() raises exception
« Reply #1 on: August 06, 2011, 01:57:09 pm »
Static objects are created, before main is entered afaik, this could explain, why you breakpoint is not triggered.

To help with the access violation you must provide more code.

Access violation usually means that you try to acess memory which has been deleted or dereference an uninitialized pointer.

Edit: Also make sure to start in debug mode.

Beta_Ravener

  • Jr. Member
  • **
  • Posts: 51
    • ICQ Messenger - 271426715
    • View Profile
Text::SetString() raises exception
« Reply #2 on: August 06, 2011, 03:00:36 pm »
This is something similar to what I do in my code:

Code: [Select]
class T{
public:
void SetString(const sf::String &string) {myText.SetString(string);}
private:
sf::Text myText;
};

class A : public T{
public:
void SetValue(const int &value) {myValue = value;}
private:
int myValue;
};

int main(){
A object;
//object.SetString("hello"); uncomment to get error
return 0;
}


This matches my code structure and reproduces the problem.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Text::SetString() raises exception
« Reply #3 on: August 06, 2011, 07:16:13 pm »
Are the classes really needed to reproduce the problem? What happens if you just instanciate a sf::Text in main() and call SetString?
Laurent Gomila - SFML developer

Beta_Ravener

  • Jr. Member
  • **
  • Posts: 51
    • ICQ Messenger - 271426715
    • View Profile
Text::SetString() raises exception
« Reply #4 on: August 07, 2011, 12:47:06 am »
Yes you're right, the classes doesn't really matter..
I started a new project and there SetString worked correctly so it's not SFML problem directly, but as I said everything works until I use that function in old project. I think it must be some weird mix of project settings that causes it. I'll try to play whit it for a while and post if find what causing it, but most probably I'll move files into new project.
Anyway, thanks for your time and help.

Edit: I compared both new and old project settings and setting this fixed it:

Configuration Properties -> C/C++ -> General -> Debug information format - set to: program database for Edit and Continue

Configuration Properties -> C/C++ -> Code Generation -> Runtime Library - set to: Multi-threaded debug DLL (/MDd) [previously was /MTd]

 

anything