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 » U++ Library support » U++ MT-multithreading and servers » Bug with socket
Bug with socket [message #31550] Sun, 13 March 2011 11:51 Go to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
App hangs, endless loop, CPU near 100% on one core.
This is only when the server is unavailable.
win32-3274

This can be duplicated with: C:\upp\reference\SocketClient
	Socket s;
	if(!ClientSocket(s, "127.0.0.1", 5024)) {


This is when compiled with Win XP with MSC9, 10 or Mingw
It runs OK in Win.

When running the app in Ubuntu 10.10 with Wine is when it hangs.

It took me more than 8 hours to track it down, much of that time
was spent looking for errors in my code.

Finally I was able to find that older versions of Upp worked OK.
Copying socket.cpp and socket.h from the older versions into the
latest (3274) worked also.

Checked to see where the problem started:
3226 and earlier OK
3233 and later it just hangs at, "if(!ClientSocket(s ...".
try/catch will not work either.

Neil

Re: Bug with socket [message #31567 is a reply to message #31550] Mon, 14 March 2011 22:55 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
I just installed upp in Ubuntu 10.10 to check this.

When compiled there the socket code does not hang.

Apparently it's just a problem with a Win .exe run with Wine in Ubuntu. I don't have any other Linux version to try with.
Re: Bug with socket [message #31569 is a reply to message #31550] Tue, 15 March 2011 07:51 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

nlneilson wrote on Sun, 13 March 2011 12:51

App hangs, endless loop, CPU near 100% on one core.
This is only when the server is unavailable.
win32-3274

This can be duplicated with: C:\upp\reference\SocketClient
	Socket s;
	if(!ClientSocket(s, "127.0.0.1", 5024)) {


This is when compiled with Win XP with MSC9, 10 or Mingw
It runs OK in Win.

When running the app in Ubuntu 10.10 with Wine is when it hangs.

It took me more than 8 hours to track it down, much of that time
was spent looking for errors in my code.

Finally I was able to find that older versions of Upp worked OK.
Copying socket.cpp and socket.h from the older versions into the
latest (3274) worked also.

Checked to see where the problem started:
3226 and earlier OK
3233 and later it just hangs at, "if(!ClientSocket(s ...".
try/catch will not work either.

Neil




What about to try ZeroMQ library?
If you have the sourcecode I can convert it.
Best regards, Ion.
Re: Bug with socket [message #31572 is a reply to message #31550] Tue, 15 March 2011 10:28 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thanks Ion but that would be more complicated than necessary.
It's basically just the code in C:\upp\reference\SocketClient\SocketClient.cpp
which hangs the same with a Win .exe run in Linux with Wine.
String snd(String r, int a){ 
	Socket s;
	if(!ClientSocket(s, "127.0.0.1", 5024)) {
	    return "x";
	}
	if(IO) s.Write(r + "\n");
	if(a==1 && IO){
    	String st = s.ReadUntil('\n');
	    return st;
	}
	return "y";
}

The code where the app hangs is:
if(!ClientSocket(..
when the server socket is not available, has not been opened, has been closed or whatever, it hangs.

Using socket.cpp and socket.h from 3226 or earlier fixes my problem.
I pointed this problem out in case someone else runs into it or if it needs to be fixed.


Neil

[Updated on: Tue, 15 March 2011 11:08]

Report message to a moderator

Re: Bug with socket [message #31606 is a reply to message #31572] Thu, 17 March 2011 09:21 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

nlneilson wrote on Tue, 15 March 2011 11:28

Thanks Ion but that would be more complicated than necessary.
It's basically just the code in C:\upp\reference\SocketClient\SocketClient.cpp
which hangs the same with a Win .exe run in Linux with Wine.
String snd(String r, int a){ 
	Socket s;
	if(!ClientSocket(s, "127.0.0.1", 5024)) {
	    return "x";
	}
	if(IO) s.Write(r + "\n");
	if(a==1 && IO){
    	String st = s.ReadUntil('\n');
	    return st;
	}
	return "y";
}

The code where the app hangs is:
if(!ClientSocket(..
when the server socket is not available, has not been opened, has been closed or whatever, it hangs.

Using socket.cpp and socket.h from 3226 or earlier fixes my problem.
I pointed this problem out in case someone else runs into it or if it needs to be fixed.


Neil

can you test "ZMQ_HelloeWorld_Srv" and "ZMQ_HelloWorld_Clnt" from bazaar?
I tried to test "ZMQ_HelloWorld_Clnt" with "SocketServer" but it seems to be incompatible.
Re: Bug with socket [message #31650 is a reply to message #31550] Fri, 18 March 2011 19:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nlneilson wrote on Sun, 13 March 2011 06:51

App hangs, endless loop, CPU near 100% on one core.
This is only when the server is unavailable.
win32-3274

This can be duplicated with: C:\upp\reference\SocketClient
	Socket s;
	if(!ClientSocket(s, "127.0.0.1", 5024)) {


This is when compiled with Win XP with MSC9, 10 or Mingw
It runs OK in Win.

When running the app in Ubuntu 10.10 with Wine is when it hangs.

It took me more than 8 hours to track it down, much of that time
was spent looking for errors in my code.

Finally I was able to find that older versions of Upp worked OK.
Copying socket.cpp and socket.h from the older versions into the
latest (3274) worked also.

Checked to see where the problem started:
3226 and earlier OK
3233 and later it just hangs at, "if(!ClientSocket(s ...".
try/catch will not work either.

Neil




Is the application single threaded or multithreaded?

Mirek
Re: Bug with socket [message #31651 is a reply to message #31650] Fri, 18 March 2011 20:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I have found some bug in error handling, but I do not think it can cause this issue. However, please check...
Re: Bug with socket [message #31667 is a reply to message #31651] Sat, 19 March 2011 03:18 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Mirek

The app is multithreaded.
I have several Upp apps with the same socket setup.
They are all good with the 3226 or earlier socket.cpp and socket.h

I just tried with 3280.

Same error on one machine and OK on another with the same version/updates for Ubuntu 10.10 and Wine 1.2.2.

Attached are 3 files
3226 has no problems
3274 hangs on both computers
3280 OK on one hangs on another.

These apps start by sending config data, no other app is required.

As mentioned this can be duplicated, same hang, with C:\upp\reference\SocketClient\SocketClient.cpp

Also I will mention again the hang is when running the .exe on Linux with Wine.

The change appears to be about the time IPv6 support was being added.

edit: One difference I noticed was 3233 through 3274 created a .buglog, 3280 does not.

Neil

[Updated on: Sat, 19 March 2011 04:48]

Report message to a moderator

Re: Bug with socket [message #31668 is a reply to message #31606] Sat, 19 March 2011 03:32 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
tojocky wrote on Thu, 17 March 2011 09:21

can you test "ZMQ_HelloeWorld_Srv" and "ZMQ_HelloWorld_Clnt" from bazaar?
I tried to test "ZMQ_HelloWorld_Clnt" with "SocketServer" but it seems to be incompatible.


I will try.
Have you tried with 3226 or earlier?

edit: How do you get to "bazaar" in theIde??

I copied the three ZMQ folders from bazaar to examples.
Both the _Srv and _Clnt have multiple errors:
ZMQ.lib(dist.obj) : error LNK2001: unresolved external symbol __imp__zmq_msg_close

Have I missed linking something?

Neil

[Updated on: Sat, 19 March 2011 05:38]

Report message to a moderator

Re: Bug with socket [message #31671 is a reply to message #31668] Sat, 19 March 2011 11:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Could you please define "hang"?

Does it stop with some kind of runtime error, or never leaves ClientSocket?
Re: Bug with socket [message #31673 is a reply to message #31671] Sat, 19 March 2011 12:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
BTW, in buglog there is:

PANIC: Missing font Times New Roman


which means you do not have Times New Roman installed on that wine. U++ cannot continue withou 3 basic fonts..
Re: Bug with socket [message #31676 is a reply to message #31673] Sat, 19 March 2011 14:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I believe the issue should be resolved, it was a combination of bug in Wine and in U++. After fixing U++, wine bug is still there, but it does not hang anymore.

Please check.
Re: Bug with socket [message #31685 is a reply to message #31550] Sat, 19 March 2011 23:05 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Mirek

What I meant by "hang" was the app would stop at this line"
if(!ClientSocket(s, "127.0.0.1", 5024)) {
I put an Exclamation("... before and after that line, the one after that line never displayed.
On a dual core one core would have CPU 98~102
On a single core it would lock up and only pushing the power button to turn the computer off, nothing else would work.

I did notice "PANIC: Missing font Times New Roman"
I spent a couple hours on the single core computer to install the MS fonts.
That probably explains why an .exe made with upp 3280 worked on that computer and not the dual core. I will not do that on the dual core since that would mean another user would have to do the same thing.

If I use the socket.cpp and socket.h from 3226 or earlier the apps .exe can be run on Win and also Linux with Wine without problems.

I will see how things go with the next update when it is released after 3280. If there are problems I can always replace the socket.cpp and socket.h from 3226 or earlier, unless that procedure gets broken.

Neil

Re: Bug with socket [message #31687 is a reply to message #31685] Sat, 19 March 2011 23:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nlneilson wrote on Sat, 19 March 2011 18:05

Hi Mirek

What I meant by "hang" was the app would stop at this line"
if(!ClientSocket(s, "127.0.0.1", 5024)) {
I put an Exclamation("... before and after that line, the one after that line never displayed.
On a dual core one core would have CPU 98~102
On a single core it would lock up and only pushing the power button to turn the computer off, nothing else would work.

I did notice "PANIC: Missing font Times New Roman"
I spent a couple hours on the single core computer to install the MS fonts.
That probably explains why an .exe made with upp 3280 worked on that computer and not the dual core. I will not do that on the dual core since that would mean another user would have to do the same thing.

If I use the socket.cpp and socket.h from 3226 or earlier the apps .exe can be run on Win and also Linux with Wine without problems.

I will see how things go with the next update when it is released after 3280. If there are problems I can always replace the socket.cpp and socket.h from 3226 or earlier, unless that procedure gets broken.

Neil




Sorry to ask, but from this long reply I cannot decode whether the issue is fixed...Smile

Well, the font is one issue - but U++ needs at least 3 basic fonts and Times New Roman is standard font in Win32. So I guess this is not our fault.

Anyway, regarding Socket hang ups, does it work now?
Re: Bug with socket [message #31688 is a reply to message #31687] Sun, 20 March 2011 00:13 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
No, it does not work with 3233 through 3280.

Replacing socket.cpp and socket.h from 3226 or earlier is a hack that can be used.

If there is something specific added to support IPv6 that calls for a MS font rather than the fonts installed by default in Ubuntu/Wine may be the problem.

Upp 3226 and earlier DOES work OK.

[Updated on: Sun, 20 March 2011 00:36]

Report message to a moderator

Re: Bug with socket [message #31689 is a reply to message #31688] Sun, 20 March 2011 07:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, but fix is in 3286...

Mirek

Re: Bug with socket [message #31690 is a reply to message #31689] Sun, 20 March 2011 08:16 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Mirek

Upp 3290 works great, no hang or lockup of computer.

THANKS!

Neil
Re: Bug with socket [message #31692 is a reply to message #31689] Sun, 20 March 2011 10:50 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

mirek wrote on Sun, 20 March 2011 08:50

Well, but fix is in 3286...

Mirek



Hello Mirek, the socket works only in single thread? What is the limitation?
Re: Bug with socket [message #32009 is a reply to message #31692] Sat, 16 April 2011 21:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
tojocky wrote on Sun, 20 March 2011 05:50

mirek wrote on Sun, 20 March 2011 08:50

Well, but fix is in 3286...

Mirek



Hello Mirek, the socket works only in single thread? What is the limitation?


Nope, MT is ok.
Re: Bug with socket [message #32013 is a reply to message #32009] Sun, 17 April 2011 13:40 Go to previous messageGo to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

mirek wrote on Sat, 16 April 2011 22:26

tojocky wrote on Sun, 20 March 2011 05:50


Hello Mirek, the socket works only in single thread? What is the limitation?


Nope, MT is ok.


Sorry for confusing.
Previous Topic: XmlRpc: possible crash fixed
Next Topic: A new function to Web Package Unicode-Escape-Javascript -> Unicode
Goto Forum:
  


Current Time: Sat Apr 20 01:10:48 CEST 2024

Total time taken to generate the page: 0.06402 seconds