Stream weirdness (linux -2 windows 1)

Archives Forums/Linux Discussion/Stream weirdness (linux -2 windows 1)

plash(Posted 2008) [#1]
Consider the following code (the THttp type is taken and modified from the code archives):

It runs perfect in win32, however in Ubuntu (Gutsy Gibbons, 7.10), it crashes on line 242 "rlnewline = ReadLine(stream)" with this "Unhandled Exception:appstub.linux signal handler 11" (debug mode is on) - which makes no sense at all.

Compiling the program without debug and running outside of maxide does nothing either - no errors pop up (if run from inside maxide, I get the signal handler error again).


Brucey(Posted 2008) [#2]
The signal handler hides the actual error the program is throwing. It is possible to change appstub.linux.c *not* to handle the error, and allow the app to nuke itself, which you can then run through gdb (for example) and see exactly where the app is breaking.
... if you know what you are doing ;-)

eg. try commenting out
signal( SIGSEGV,sighandler );


Just be careful.


Actually, it would be nice if BlitzMax didn't catch this at all for debug builds - would make life easier in certain cases...


plash(Posted 2008) [#3]
Be careful eh!?

it would be nice if BlitzMax didn't catch this at all for debug builds
I don't know why you say "Just be careful" (inform me), but wouldn't this just be fine?
?NotDebug 'I know NotDebug is not valid - I can't remember any of them EDIT: oh wait, you can do this "?Not Debug"
	signal( SIGSEGV,sighandler );
?


Anyways, now all I'm getting is "Segmentation fault (core dumped)". :(

EDIT: Using debugstop just before the loop that contains the line its crashing on does a "Segmentation fault (core dumped)" error again..


Brucey(Posted 2008) [#4]
well, no.. ?NoDebug is a BlitzMax thing.. that code is C.

Now you have a segmentation fault... you can run your app with gdb, for example :
gdb ./myappname

in gdb, type the letter "r", followed by return. (no quotes!).
Then, when it crashes, type "bt", followed by return (no quotes!).

That should qive you a "back trace" showing where it was when it crashed.

to quit gdb, type quit :-)


plash(Posted 2008) [#5]
I suppose I have no idea what I'm doing.

Here is the output on gdb:

I have no idea what any of that means.


Brucey(Posted 2008) [#6]
well, that was less than useful, hey?

That generally means (given the lack of labels) that it's specifically a line of BlitzMax's generated assembler that's broken - otherwise you tend to get a C function name if something went wrong elsewhere.

Your next task, should you choose to accept it, is to debug your code. Hope you've nothing else to do today ;-)


Brucey(Posted 2008) [#7]
Perhaps the stream handle is null or something.

Stick a debugstop in there and examine the variables.


plash(Posted 2008) [#8]
Hope you've nothing else to do today ;-)
That would be a tonight for me sir.

I am not liking max on Linux right now :/, ironically the graphics issue, and this, are both required to work for my current project.

Thanks for the help, I'll post my findings tomorrow - unless I manage to find the problem before I hit the sack.

EDIT:
well, no.. ?NoDebug is a BlitzMax thing.. that code is C.
After many late nights, I would say it is fair to say I am less attentive to details at night :)


D4NM4N(Posted 2008) [#9]
It seems to me Signal handler 11 is similar to b3Ds MAV.

What line in the debugger is it terminating on?
If its terminating deeper then try adding lines like:

debuglog 342349872(a random number)

in progressive locations in your code and you will see in the terminal which was the last number before the crash to progressively narrow it down.


dawlane(Posted 2008) [#10]
Code works ok in Ubuntu 8.04.
Just on the off chance make sure that your compiling against gcc-3.3 and not system linking to gcc-4.2/4.1 and the libxml2 libs are installed.

Here's a list of the sig codes http://www.comptechdoc.org/os/linux/programming/linux_pgsignals.html


plash(Posted 2008) [#11]
I just got libxml2 (note that I'm on 8.04 now) and removed all symlinks of gcc, still getting 'Segmentation fault'.


EDIT:
If I change the read loop to this
Local ln:Int = 0
			DebugLog "getcontent"
			While Not Eof(stream) 
					rlnewline = ReadLine(stream)
				ln:+1
				DebugLog ln
				buffer:+ rlnewline + "~n"
				
			Wend

The last DebugLog message is ALWAYS 41.. (there are currently 141 lines in the xml file)

P.S. Does anyone have a gtk compiled version of maxide working? my ldconfig has
/usr/lib/firefox/libgtkembedmoz.so
/usr/lib/firefox/

in it, but I get this from terminal
./maxide: error while loading shared libraries: libgtkembedmoz.so: cannot open shared object file: No such file or directory

Have things changed in firefox 3.0? (it worked fine on 7.10)


plash(Posted 2008) [#12]
After removing all symlink files that had gcc-x.x in them, and reinstalling gcc-3.3 I tried to rebuild all modules and got this:
Compiling:freeaudio.cpp
ar: creating /home/timhow/BlitzMax/mod/pub.mod/zlib.mod/zlib.debug.linux.x86.a
gcc-3.3: installation problem, cannot exec `cc1plus': No such file or directory
Build Error: failed to compile /home/timhow/BlitzMax/mod/pub.mod/freeaudio.mod/freeaudio.cpp
Process complete

I looked for cc1plus and anything similar in synaptics but found nothing.


dawlane(Posted 2008) [#13]
After removing all symlink files that had gcc-x.x in them.


I think this is where you went wrong here.
Re-install gcc-4.2 and then reinstall gcc-3.3

Some people make a system link named g++-3.3 that links to g++-4.2 ( or g++ which is a system link in it's self to the current compiler suit ) to force BlitzMax to use gcc-4.x/g++-4.x

BlitzMax for some reason looks to be hard-coded to use the gcc-3.3 suit of tools.

Check to see if you have these packages installed after re-installing gcc-4.2

cpp
cpp-4.2
cpp-3.3
gcc
gcc-3.3-base
gcc-4.2-base
libgcc1
g++
g++-3.3
g++-4.2
libstdc++6 ( or/and ) libstdc++5

All versions of gcc/g++ will live quite happily side by side. The only problems that you may have is if you are using the 64bit edition of ubuntu. The problem there is that there is only a 64bit version of the gcc-3.3 libs where as gcc-4.1/gcc-4.2 has both the 64bit and 32bit libs.

cc1plus

Is part of the gcc suit and can be found in...
/usr/lib/gcc-lib/i486-linux-gnu/3.3.6 (if gcc-3.3 is installed)
or in a sub-directory of
/usr/lib/gcc/i486-linux-gnu/

Is Ubuntu 8.04 an upgrade or a clean install ?


plash(Posted 2008) [#14]
Nope, another upgrade. It's a pain in the arse to install linux on a computer with no cd drive.

EDIT: I did not remove any g++ symlinks, but I am trying what you suggested.

EDIT2: Compiling modules! w00t.


plash(Posted 2008) [#15]
!!! That worked, thanks. It seems like I was compiling everything before in gcc-4.2, going to try graphics stuff again.


dawlane(Posted 2008) [#16]
It's a pain in the arse to install linux on a computer with no cd drive.

I wonder if there is a way to install off a USB pen drive ?

I do know that you can install ubuntu into a USB pen drive.

Edit: There is as long as your machine can boot off of a usb drive. https://help.ubuntu.com/community/Installation/FromUSBStick


plash(Posted 2008) [#17]
I tried to get usb stick to work. Can't remember what put me off, but if I need to reinstall linux I'll take a look at that first.

BTW, graphics work now! :)