I thought the following might be of interest here. It appeared on Redhat's Alpha list. ---------- Forwarded message ---------- Date: Sat, 27 Nov 1999 16:50:15 -0700 (MST) From: Michal Jaegermann <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: Links (web browser) Jurij Smakov wrote: > > It is called "links" and home page is > > http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/links/ > ... > Unfortunately, it does not run on Alpha "out-of-the-box" (it compiles ok, > but segfaults), No, actually "compiles ok" is very far from beeing the case. If you try to compile with -Wall (which you always should as an obvious thing to do) then, among multiple other things you will see these: gcc -DHAVE_CONFIG_H -I. -I. -I. -O2 -g -Wall -c html.c html.c: In function `new_menu_item': html.c:1151: warning: cast to pointer from integer of different size html.c: In function `menu_labels': html.c:1211: warning: cast from pointer to integer of different size html.c: In function `menu_contains': html.c:1218: warning: cast from pointer to integer of different size gcc -DHAVE_CONFIG_H -I. -I. -I. -O2 -g -Wall -c html_r.c html_r.c: In function `html_special': html_r.c:548: warning: cast to pointer from integer of different size gcc -DHAVE_CONFIG_H -I. -I. -I. -O2 -g -Wall -c menu.c menu.c: In function `display_codepage': menu.c:244: warning: cast from pointer to integer of different size menu.c: In function `assumed_codepage': menu.c:252: warning: cast from pointer to integer of different size menu.c: In function `charset_list': menu.c:273: warning: cast to pointer from integer of different size session.c: In function `add_time_to_str': session.c:38: warning: int format, different type arg (arg 3) session.c:39: warning: int format, different type arg (arg 3) session.c:39: warning: int format, different type arg (arg 4) session.c:40: warning: int format, different type arg (arg 3) session.c:41: warning: int format, different type arg (arg 3) session.c: In function `do_move': session.c: In function `win_func': session.c:1082: warning: cast to pointer from integer of different size session.c:1082: warning: cast to pointer from integer of different size gcc -DHAVE_CONFIG_H -I. -I. -I. -O2 -g -Wall -c terminal.c terminal.c: In function `in_term': terminal.c:278: warning: cast from pointer to integer of different size terminal.c: In function `close_handle': terminal.c:556: warning: cast from pointer to integer of different size terminal.c: In function `unblock_terminal': terminal.c:563: warning: cast to pointer from integer of different size terminal.c: In function `exec_on_terminal': terminal.c:596: warning: cast to pointer from integer of different size gcc -DHAVE_CONFIG_H -I. -I. -I. -O2 -g -Wall -c types.c types.c: In function `add_ct_fn': types.c: In function `really_del_ct': types.c:187: warning: cast from pointer to integer of different size types.c: In function `menu_del_ct': types.c:199: warning: cast from pointer to integer of different size types.c: In function `menu_add_ct': types.c:217: warning: cast from pointer to integer of different size types.c: In function `add_ext_fn': types.c: In function `really_del_ext': types.c:362: warning: cast from pointer to integer of different size types.c: In function `menu_del_ext': types.c:374: warning: cast from pointer to integer of different size types.c: In function `menu_add_ext': types.c:390: warning: cast from pointer to integer of different size gcc -DHAVE_CONFIG_H -I. -I. -I. -O2 -g -Wall -c url.c gcc -DHAVE_CONFIG_H -I. -I. -I. -O2 -g -Wall -c view.c view.c: In function `selected_item': view.c:1220: warning: cast from pointer to integer of different size You can possibly get away with the stuff in html.c. Parts in session.c, terminal.c and types.c are obviously quite broken - even on Intel regardless of the fact that there you can pretend that nothing happened. The author is, at least partially, aware of this as you can see a comment like: /* !!! FIXME: doesn't work on 64b machines */ in terminal.c. Also various structures are laid out and used in such manner that one gets tons of an 'unaligned access' even before the program really started. The bomb on a startup is caused directly by a struct event { int ev; int x; int y; int b; }; defined like that in links.h. In a function 'win_func()' from session.c an attempted use (shudder!) is as follows: read_session_info(win->term->fdin, ses, (char *)ev->b + sizeof(int), *(int *)ev->b)) where 'ev' is a pointer to something of a 'struct event' type. Dereferencing a pointer which was first cut to 'int' is not going to fly, I am afraid, and one gets a well deserved SIGSEGV. The program is likely easier to fix than Mozilla :-) but it is highly unfortunate that even nowadays people are writing a new code in such sloppy manner. "Porting to Alpha" should be understood as an overpolite translation of "fixing nasty bugs" (like using "%d" format in sprintf to store in variables which were even __declared__ as long). It may be not as easy to fix as you may think; interdependencies can be quite convoluted and catching all function calls where you can loose half of your pointer and misalign a stack can be quite a task after not so small chunk of code was already written. Michal -- To unsubscribe: send e-mail to [EMAIL PROTECTED] with 'unsubscribe' as the subject. Do not send it to [EMAIL PROTECTED] Janina Sajka, Director Information Systems Research & Development American Foundation for the Blind (AFB) [EMAIL PROTECTED]
