Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Segmentation fault in Terminal (Leopard)

I posted my topic previously in a wrong place maybe. I think here's the most appropriate place.

Today I received my new iMac 2.66. I installed some applications, in particular a mathematical application, named GAP. I've used such application for several months on my Macbook, running Tiger. I had never problems. After installing succesfully GAP on the new iMac, I launched it from the Terminal. I performed some computations, but quite immediately the program exited with a segmentation fault error. Basically, I cannot do anything with this application, because every time it exits with a segmentation fault. Two hours ago I came up with the idea of installing iTerm on the iMac. Well, I launched GAP from iTerm and I experienced no problem. What I think now is that Terminal has some bugs. It sounds really strange. Maybe you have some clues. Thank you in advance.

iMac 2.66, Mac OS X (10.5.6)

Posted on Mar 21, 2009 4:40 PM

Reply
9 replies

Mar 21, 2009 6:09 PM in response to pigreco

What I think now is that Terminal has some bugs. It sounds really strange.

About the only way I can think any terminal emulator could affect an applications is how it handles escape sequences. That is to say, some keys send escape sequences to the application, such as the arrow keys, the F1-F20 keys, the Home, End, Page Up, Page Down, etc... kind of keys.

Also there are a few escape sequences that an applications can send to the terminal emulator that cause it to respond with a reply escape sequence, such as what is the current cursor location, the screen size, etc...

Another possibility is if the application uses the "curses" package which behaves differently depending on the setting of the TERM environment variable. And in this case Terminal may be using a different TERM setting than iTerm. If they are different, try setting Terminal's TERM environment variable the same as iTerm's

export TERM=??????

Mar 22, 2009 4:06 AM in response to BobHarris

Thank you for the answer.

I tried to change the TERM environment variable. Now iTerm and Terminal TERM are xterm. But Terminal is unstable. I say unstable, because sometimes, if I quit Terminal and restart Terminal and then I launch GAP application it works without problems. That means I can perform any kind of computation with GAP and no segmentation fault error happens. But if I restart the computer and then I launch Terminal, I cannot predict if it works or not. It's so strange..

Mar 22, 2009 4:36 AM in response to pigreco

First, iTerm is a nice terminal emulator, and it is what I use every day. I spend lots of time in iTerm. So continue using it if it gets the job done.

Are all the environment variables the same when running Terminal vs iTerm?

Does GAP segfault and you are back at the shell prompt? If so, it is a bug in GAP that is being uncovered by using Terminal. That may be caused by Terminal sending an escape sequence that GAP is not prepared to handle.

If Terminal dies and you have to restart Terminat, then Terminal has a bug and you should report it to Apple via <http://www.apple.com/feedback>

No matter where the bug is, this does not get your work done. So I would suggest continuing with iTerm.

Mar 22, 2009 4:58 AM in response to BobHarris

Well, I post here the environment variables:

MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man
TERM PROGRAM=AppleTerminal
TERM=xterm
SHELL=/bin/bash
TMPDIR=/var/folders/em/emRM0mnoH 0Bssgdm7B0dE++TI/-Tmp-/
Apple PubSub_SocketRender=/tmp/launch-w4sssv/Render
TERM PROGRAMVERSION=133-1
USER=simone
COMMAND_MODE=legacy
SSH AUTHSOCK=/tmp/launch-FPket0/Listeners
_CF_USER_TEXTENCODING=0x1F5:0:4
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PWD=/Users/simone
SHLVL=1
HOME=/Users/simone
LOGNAME=simone
DISPLAY=/tmp/launch-r76nFs/:0
SECURITYSESSIONID=919070
_=/usr/bin/env

For iTerm:
MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man
LC MONETARY=itIT.UTF-8
TERM_PROGRAM=iTerm.app
TERM=xterm
SHELL=/bin/bash
TMPDIR=/var/folders/em/emRM0mnoH 0Bssgdm7B0dE++TI/-Tmp-/
Apple PubSub_SocketRender=/tmp/launch-w4sssv/Render
LC NUMERIC=itIT.UTF-8
USER=simone
COMMAND_MODE=legacy
SSH AUTHSOCK=/tmp/launch-FPket0/Listeners
_CF_USER_TEXTENCODING=0x1F5:0:4
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
LC MESSAGES=itIT.UTF-8
LC COLLATE=itIT.UTF-8
PWD=/Users/simone
LANG=it_IT.UTF-8
SHLVL=1
COLORFGBG=0;15
HOME=/Users/simone
LOGNAME=simone
LC CTYPE=itIT.UTF-8
DISPLAY=/tmp/launch-r76nFs/:0
LC TIME=itIT.UTF-8
_=/usr/bin/env

About the kind of error, GAP segfault and I am back at the shell prompt. According to your post, it seems a GAP error. But, how I wrote, I have no problems with Terminal on my Macbook with Tiger. That suggests that is a combination of Terminal+Leopard.

Mar 22, 2009 9:14 AM in response to pigreco

The following iTerm environment variables do not exist for your Terminal environment:

# found in iTerm environment variables (NOT in Terminal)
COLORFGBG=0;15 # seems to be Color Foreground/Background info
LANG=it_IT.UTF-8
LCCOLLATE=itIT.UTF-8
LCCTYPE=itIT.UTF-8
LCMESSAGES=itIT.UTF-8
LCMONETARY=itIT.UTF-8
LCNUMERIC=itIT.UTF-8
LCTIME=itIT.UTF-8

I do not know if this would have an affect on GAP or not, but it is a difference that affects how programs process strings, print, terminal reads, etc...

Have you tried setting these environment variables in Terminal before using GAP? I'm not sure that they would or would not change things, but it is a difference related to date input/output handling which is where Terminal is involved with GAP.

And like I said, there is very little that Terminal can do to directly affect the process GAP. It does not provide any system services, it does not provide any memory management, it does does not provide the process GAP runs in, it actually does very little.

The only connection between GAP and Terminal is the standard in, standard out, and standard error I/O ports. That basically means the characters sent back and forth between GAP and Terminal. And the most likely type of characters that could cause trouble would be escape sequences, especailly query sequences from GAP to Terminal and where Terminal reponds to the query. If the response in Leopard Terminal is different from the response in Tiger, then that might expose a bug in GAP that GAP is not prepared to handle the differently formatted escape sequence.

This difference could be totally within the ANSI terminal emulator standards, but not typical of other terminal emulators send, or it could be a bug in Terminal. But regardless of what Terminal sends, no well written applications should ever trust the input it receives from the outside world, and thus if it crashes because of input, then it is the fault of the application.

For example, I write file system code for a living (Unix and Linux systems). If I decided to crash the operating system because someone misspelled the name of a file, no one would be happy, and while the misspelling was on the part of the user and thus their error, that is no excuse for code I write to die because of bad input. And this applies to GAP.

I would suggest you report the GAP seqfault to the GAP developers so that they have a chance to correct it. And if you really think it is an Apple Terminal error as root cause, give feedback to Apple via the previously mentioned feedback link.

And in the meantime, use iTerm so you can get your work done.

Mar 22, 2009 10:54 AM in response to BobHarris

Maybe I solved my problem. Unfortunately it was not a problem of variables. I mean, I set the environment variables. But the problem seems to depend on the window size (!!). Now I explain. As you know you can set the Terminal size in the form (rows, columns). Well, it seems that if you set the number of columns greater than 266, then the application GAP crahses. It can crash with a Bus Error or Segmentation Fault. I set a value lower than 266 and now I can execute GAP from Terminal too. Moreover, if I set the number of column greater than 266 in iTerm I have the same errors! In iTerm I had previously no errors, because the font in iTerm was greater so the column number was less than 266. Using the same font that I use in Terminal, I can set a greater number of columns in iTerm. In such a way I experience the same errors.

Now, do you think that an application can have such errors depending on the size of the window?

Mar 22, 2009 2:54 PM in response to pigreco

Now, do you think that an application can have such errors depending on the size of the window?

Yes. This is either a GAP error or an error with some library software GAP is using to control the information it displays on the screen.

In any event, it looks like this is not related to the terminal, but a problem in the application or the run-time libraries used by the application, all of which is totally independent of the terminal emulator.

For example, the application could have sized some line buffer to 255 characters (a common size in programs), and when the lines for the screen were 266 characters, the buffers overflowed, variables totally unrelated to displaying text got corrupted. If that buffer was on a subroutine stack, the overflow could have corrupted a return address and when the routine returned it might have jumped into never-never-land. Or an adjacent memory location was a pointer, and when the code attempted to use the pointer after it was corrupted, it accessed memory outside the applications allowed space.

This is the kind of bug you report to the GAP developers along with information on how to reproduce it.

Segmentation fault in Terminal (Leopard)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.