Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » MSC15 and 2014 sources - problem with Stream
MSC15 and 2014 sources - problem with Stream [message #46742] Fri, 22 July 2016 08:26 Go to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Hello,

I already started a thread on a wrong forum, please move or delete the Thread from there and put it in here.
http://www.ultimatepp.org/forums/index.php?t=msg&th=9720 &start=0&

My problem is, I'm using the latest Upp (9251) with 2014 sources and compile with MSC15.
But when I call Cout() in my prog, it crashes.
This only happens with MT flag and in optimal mode (debug runs fine)

The same error can be produced on the newest 2015 sources, when putting CoutUTF8() before the first Cout().
I'm running Win 10 Pro.

You can see the error in the other thread as well, but it's:
Exception at 0x00AB60C7 (address changes every time) in (Projectname).exe: 0xC0000005:
Access violation at read at position 0x0000004.


The error seems to occur in function void Stream::Put(const char *s).
See attachment.

Thanks for the quick reply, as I need this program really quick.

//edit:
Okay guys, I'm kind of confused now.
When I start the little test program from the other thread with 2015 sources, it works fine. In 2014 sources, it crashes.
BUT, when I start MY program in 2015 sources, it crashes as well as on 2014 sources.
Very confusing.
Any help would be very appreciated.......
  • Attachment: crash.png
    (Size: 166.61KB, Downloaded 271 times)

[Updated on: Fri, 22 July 2016 09:45]

Report message to a moderator

Re: MSC15 and 2014 sources - problem with Stream [message #46743 is a reply to message #46742] Fri, 22 July 2016 10:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Do you call Cout from threads?
Re: MSC15 and 2014 sources - problem with Stream [message #46744 is a reply to message #46743] Fri, 22 July 2016 10:23 Go to previous messageGo to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
In this particular example, no.
My code starts as following:
CONSOLE_APP_MAIN
{
    String cmd = "";
    const Vector<String>& argc = CommandLine(); 
    if (argc.GetCount()>0)
        cmd = argc[0];

    bool progCheck = true;
    for (int c=0;c<argc.GetCount();c++)
    {
   		//if(_stricmp(argv[c], "noProgCheck") == 0)
   		if(argc[c] == "noProgCheck")
		{	progCheck = false;
			break;
		}
    }
  
    Cout() << "\n-----------------------------------\n";
    Cout() << PROG_DESCRIPTION;
    Cout() << "   ";
    Cout() << PROG_COPYRIGHT;
    Cout() << "\n";
    Cout() << "Rel.: ";
    Cout() << PROG_VERSION;
    Cout() << " / ";
    Cout() << DATABASE_VERSION;
    Cout() << " ";
    Cout() << cmd;
    Cout() << "\n-----------------------------------\n";


and crashes at the very first Cout().
We use sockets in this program as well, that's why we need MT.

It seems to be a compiler problem, as it happens with 2014 sources and 2015 sources.
The funny thing is, that my little testprogram worked...
And when we compile our program with older upp (same sources though), and older compiler (VS2012) it works fine.

Do you know any compiler flag we should try??
Re: MSC15 and 2014 sources - problem with Stream [message #46745 is a reply to message #46744] Fri, 22 July 2016 11:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Looking at screenshot, I have to say I am a bit confused what is "sources" and what is "compiler"

Looks like you are using in Visual Studio to compile?

Mirek
Re: MSC15 and 2014 sources - problem with Stream [message #46746 is a reply to message #46745] Fri, 22 July 2016 11:51 Go to previous messageGo to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Not to compile but to debug, because VS has more capabilities in debugging release/optimal versions.
May I can call you and you can do a TV session?
Because I don't know what to do anymore.
Things are very strange... Because our project works fine with 2012 compiler and 2014 sources.
But won't work with 2014 sources and 2015 compiler.
And it won't work with 2015 sources and 2015 compiler either.
When I do a little testprog, it works with 2015 sources, but won't with 2014. Compiler is 2015.
I think it's better if you actually see what I do...

Sources = Uppsrc
Compiler = MSC15

//edit: I did get another error recently, but only once and I didn't made a screenshot, sorry. But the callstack said something like: Put > printf (is put really calling printf?!) > lambda ....
So, could it be some sort of C++11 issue?

[Updated on: Fri, 22 July 2016 13:39]

Report message to a moderator

Re: MSC15 and 2014 sources - problem with Stream [message #46747 is a reply to message #46746] Fri, 22 July 2016 15:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
It really looks like Cout is not properly initialized...

Mirek

[Updated on: Fri, 22 July 2016 15:58]

Report message to a moderator

Re: MSC15 and 2014 sources - problem with Stream [message #46748 is a reply to message #46747] Fri, 22 July 2016 16:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Try to replace

Stream& Cout()
{
return Single<CoutStream>();
}


with

Stream& Cout()
{
static CoutStream x;
return x;
}
Re: MSC15 and 2014 sources - problem with Stream [message #46749 is a reply to message #46748] Mon, 25 July 2016 09:13 Go to previous messageGo to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Hi mirek,

thanks, works like a charm now.

Could you explain what happened?
Must be a ONCELOCK issue?!
Re: MSC15 and 2014 sources - problem with Stream [message #46750 is a reply to message #46749] Mon, 25 July 2016 15:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I am afraid that this is in fact very bad news....

It looks like MSC15 sometimes has troubles with static inside template (as in Single) Sad I have already experienced something somewhat similar. It looks like only some installations of MSC15 are affected though, compile on different computer and it works.

Mirek
Re: MSC15 and 2014 sources - problem with Stream [message #46753 is a reply to message #46750] Tue, 26 July 2016 10:33 Go to previous messageGo to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Well, it seems like there are more and more problems coming up with MSC15, this time with 2010 sources (in another project).
A simple Format("%s %d", "bla", 1); results in a crash in optimal mode, debug works fine though.
Exception: C0000005 at 150C170
EXCEPTION_ACCESS_VIOLATION
reading at 0000001C


Callstack is in the picture.
Thanks for help.

//edit: Same fix seems to work. I changed Single to:
template <class T>
T& Single() {
	#ifndef flagMSC15
	static T *p;
	ONCELOCK {
		static T o;
		p = &o;
	}
	return *p;
	#else
	static T x;
	return x;
	#endif
}
  • Attachment: crash.png
    (Size: 149.59KB, Downloaded 237 times)

[Updated on: Tue, 26 July 2016 11:33]

Report message to a moderator

Re: MSC15 and 2014 sources - problem with Stream [message #46754 is a reply to message #46753] Wed, 27 July 2016 06:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Actually, that sounds like a good news for a change. For C++11, this is a correct implementation. The whole point of Single was that before C++11, this code was not MT safe.

Mirek
Re: MSC15 and 2014 sources - problem with Stream [message #46755 is a reply to message #46754] Wed, 27 July 2016 08:38 Go to previous message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Well, all projects seem to work for now, maybe we face some detailed errors when we test specific packages/functions, but a first test was fine.

Thanks for the help!
Previous Topic: StdDisplayClass - a very useful class. Expand for all fonts
Next Topic: [Solved] Instant Upp crash on char input
Goto Forum:
  


Current Time: Fri Mar 29 08:25:39 CET 2024

Total time taken to generate the page: 0.01289 seconds