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++ » Bugs (& fixes) » Crash on Cout with MSC15
Crash on Cout with MSC15 [message #46722] Wed, 20 July 2016 16:12 Go to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Hello,

// edit:
For those who don't want to read all the text below:
What changes have to be done to 2014 sources that MT flag will work with MSC15 like newest (2015) sources do???
Thanks Wink

-----

I formated my Laptop recently and decided to install the newest version of Upp and MS VS afterwards.
So I installed Upp 2015.2 (Version 9251) and MS Visual Studio Community 2015 (which is free to download).
I work on a Windows 10 Pro N Laptop.

So, after a few tweaks here and there, everything seems to work fine (despite the Win XP incompatibility, but thats okay)
BUT, I discovered one error which drives me nuts...

Cout() doesn't seem to work properly... printf is no problem though.
Sure I could change all Cout() calls to printf but that's not a solution.

The funny thing is, in debug everything works fine, only in optimal the program crashes immediately.
I tried to debug the optimal version in Visual Studio, the error seems to be in:
void Stream::Put(const char *s)
{
	while (*s) Put(*s++);
}


The error is always the same: (The error is german and I tried to translate it to english as good as I can)
Exception at 0x00AB60C7 (address changes every time) in (Projectname).exe: 0xC0000005:
Access violation at read at position 0x0000004.


But the funniest thing is, that this must be something depending on my includes (it's a rather big project)
Because, I made a new test application, only containing the following code:
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	Cout() << "\n-----------------------------------\n";
	ReadStdIn();
}

and this just works fine, using the SAME sources as the big project.
The \n----... is also the first line in my other project.

Any suggestions?
Any help is very appreciated!

I also tried differend compiler flags (GS) and sources (2014, 2015), always the same result...
Everything works, except my "old" project.

//edit: I narrowed it down to the MT flag... Please just create a new multithreaded console project with the content I posted above and try it... It will crash. But why?

//edit2: Okay, only 2014 sources are affected. The newest sources work fine with MT... I'm on it. Please keep this thread if other people have the same issue

[Updated on: Wed, 20 July 2016 16:26]

Report message to a moderator

Re: Crash on Cout with MSC15 [message #46723 is a reply to message #46722] Wed, 20 July 2016 16:34 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 265
Registered: July 2011
Location: Bangalore
Experienced Member
Hi,

In new release "optimal" mode is deprecated.
Quote:
The funny thing is, in debug everything works fine, only in optimal the program crashes immediately.
I tried to debug the optimal version in Visual Studio, the error seems to be in:


Check flags for "release" mode.

Or check with "Optimized speed" mode. I faced similar issues with optimal mode.


Warm Regards

Deepak
Re: Crash on Cout with MSC15 [message #46724 is a reply to message #46723] Wed, 20 July 2016 16:43 Go to previous messageGo to next message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Thanks for the quick answer,

as I discovered, it has something to do with MT flag and the changes from 2014 sources to 2015.
Because the crash only appears in MT with 2014 sources.
MT on 2015 work fine...

I think there must be a significant difference... But where?!
Must be something about that encoding and converting stuff, right?

-

Which flags do you mean exactly, because there are sooo many different flag and option menus in Upp.
But if you mean the Setup > Build options, I got:
Common options: /bigobj /D_ATL_XP_TARGETING /FS
Debug options: -Od
Debug link options: /STACK:20000000
Optimize for speed: -O2
Optimize for size: -O1
Release link options: same as Debug link options

[Updated on: Wed, 20 July 2016 16:54]

Report message to a moderator

Re: Crash on Cout with MSC15 [message #46732 is a reply to message #46724] Thu, 21 July 2016 07:24 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 265
Registered: July 2011
Location: Bangalore
Experienced Member
Hi,

Please check when this gets called first time

void Stream::Put(const char *s)

pointer points to valid "cstring"


Warm Regards

Deepak
Re: Crash on Cout with MSC15 [message #46733 is a reply to message #46732] Thu, 21 July 2016 08:25 Go to previous message
NilaT is currently offline  NilaT
Messages: 70
Registered: November 2011
Location: Austria
Member
Could somebody please confirm the following?
New Console App in latest upp with latest sources, MSC15 on Win 10.
Compile and run in optimal with MT flag!
Code:
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	CoutUTF8(); // Without this line, works perfect. With this line = crash (same error as with 2014 upp sources)
	Cout() << "\n-----------------------------------\n";
	ReadStdIn();
}


And explain me where and why?
Thanks.

--------------

//edit: Because we work with 2014 sources in our project, please forget that 2015 example.
I tried to apply the changes in CoutStream from 2015 to 2014 sources, because I thought a wrong Charset causes the error.
Afterwards I edited the Stream::Put method:
void Stream::Put(const char *s)
{
	while (*s)
	{
		Put(*s);
		*s++;
	}
}


In debug, Put calls void Put(int c) in Stream.h:
void      Put(int c)             
{ 
  if(ptr < wrlim) 
    *ptr++ = c; 
  else 
    _Put(c); 
}

and then calls _Put, which, in endeffect calls the "new" Put0 which converts the charset.

BUT, in optimal, the error raises in Stream::Put -> Put call.
I debug in Visual Studio, put a Breakpoint on the Put(*s); call and press F11, but I can't jump into the function...

What the heck...

// edit:
I tried to compile our project with 2015 sources, same result.
Debug runs fine, optimal crashes.

I attach a pick of our project, compiled with 2014 sources and MSC15 in optimal.
  • Attachment: crash.png
    (Size: 166.61KB, Downloaded 300 times)

[Updated on: Thu, 21 July 2016 13:04]

Report message to a moderator

Previous Topic: Dont work Debug F5
Next Topic: Since Raspberry have not RTC clock, I propose add SetTime functionality
Goto Forum:
  


Current Time: Thu Nov 14 06:39:29 CET 2024

Total time taken to generate the page: 0.02812 seconds