* Any C++ on Alpha gfurus out there?
@ 1998-11-13 19:10 Brian E.W. Wood
1998-11-13 19:17 ` Nicholas Sallembian
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Brian E.W. Wood @ 1998-11-13 19:10 UTC (permalink / raw)
To: axp-list
I'm trying to compile the most recent versions of AbiWord, a promising project
to create a GPL wysiwyg word processor.
As of recent versions is has stopped working on my Alpha. It apparently
comtinues to run on Intel machines.
I'm definitely not a C++ programmer, but I'd like to try and find out what has
happened.
The program segfaults on the following bit of code:
const char * EV_UnixMenu::_getItemPath(AP_Menu_Id id) const
{
for (UT_uint32 k=0; (k < m_nrActualFactoryItems); k++)
{
_wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
if (wd && (wd->m_id==id))
return m_menuFactoryItems[k].path;
}
GDB says it segfaults at the if statement.
UT_uint32 is defined in the header file:
protected:
UT_uint32 m_nrActualFactoryItems;
UT_Vector m_vecMenuWidgets;
I realize that this is woefully inadequate information with which to diagnose
the problem but I'm hoping somebody might have an inspired guess as to what
direction I should proceed in. is the uint32 perhaps a problem on the alpha?
Thanks.
---
Brian E.W. Wood beww@intac.com
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:10 Any C++ on Alpha gfurus out there? Brian E.W. Wood
@ 1998-11-13 19:17 ` Nicholas Sallembian
1998-11-13 19:25 ` B. James Phillippe
1998-11-13 19:26 ` Anders Hammarquist
1998-11-13 19:37 ` Heinz Ulrich Stille
1998-11-16 13:15 ` Stefan Schroepfer
2 siblings, 2 replies; 15+ messages in thread
From: Nicholas Sallembian @ 1998-11-13 19:17 UTC (permalink / raw)
To: beww; +Cc: axp-list
Try this code :
const char * EV_UnixMenu::_getItemPath(AP_Menu_Id id) const
{
for (UT_uint32 k=0; (k < m_nrActualFactoryItems); k++)
{
_wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
if (wd)
if (wd->m_id==id)
return m_menuFactoryItems[k].path;
}
There might be a problem in the order the if expression is evaluated : if wd is
NULL and wd->m_id is evaluated first... Crash !
Nicolas
Brian E.W. Wood wrote:
> I'm trying to compile the most recent versions of AbiWord, a promising project
> to create a GPL wysiwyg word processor.
>
> As of recent versions is has stopped working on my Alpha. It apparently
> comtinues to run on Intel machines.
>
> I'm definitely not a C++ programmer, but I'd like to try and find out what has
> happened.
>
> The program segfaults on the following bit of code:
>
> const char * EV_UnixMenu::_getItemPath(AP_Menu_Id id) const
> {
> for (UT_uint32 k=0; (k < m_nrActualFactoryItems); k++)
> {
> _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
> if (wd && (wd->m_id==id))
> return m_menuFactoryItems[k].path;
> }
>
> GDB says it segfaults at the if statement.
>
> UT_uint32 is defined in the header file:
>
> protected:
> UT_uint32 m_nrActualFactoryItems;
> UT_Vector m_vecMenuWidgets;
>
> I realize that this is woefully inadequate information with which to diagnose
> the problem but I'm hoping somebody might have an inspired guess as to what
> direction I should proceed in. is the uint32 perhaps a problem on the alpha?
>
> Thanks.
>
> ---
> Brian E.W. Wood beww@intac.com
>
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:17 ` Nicholas Sallembian
@ 1998-11-13 19:25 ` B. James Phillippe
1998-11-13 21:48 ` Nicholas Sallembian
1998-11-14 1:06 ` Bob McElrath
1998-11-13 19:26 ` Anders Hammarquist
1 sibling, 2 replies; 15+ messages in thread
From: B. James Phillippe @ 1998-11-13 19:25 UTC (permalink / raw)
To: axp-list
On Fri, 13 Nov 1998, Nicholas Sallembian wrote:
> Try this code :
...
> if (wd)
> if (wd->m_id==id)
...
> There might be a problem in the order the if expression is evaluated : if
> wd is NULL and wd->m_id is evaluated first... Crash !
[over the original code] :
> > if (wd && (wd->m_id==id))
I sincerely hope that is not the problem; it is very clearly defined in the
C programming language that logical AND and OR operations proceed from left
to right.
-bp
--
B. James Phillippe . bryan@terran.org
UNIX Software Engineer . http://www.terran.org/~bryan
Member since 1.1.59 . finger:bryan@earth.terran.org
MOTM: Waiting for the DSL to go in :/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:25 ` B. James Phillippe
@ 1998-11-13 21:48 ` Nicholas Sallembian
1998-11-14 1:06 ` Bob McElrath
1 sibling, 0 replies; 15+ messages in thread
From: Nicholas Sallembian @ 1998-11-13 21:48 UTC (permalink / raw)
To: axp-list
My apologizes for that rough error. I should not have said that without
actually trying the code ...
Nicolas.
B. James Phillippe wrote:
> On Fri, 13 Nov 1998, Nicholas Sallembian wrote:
>
> > Try this code :
> ...
> > if (wd)
> > if (wd->m_id==id)
> ...
> > There might be a problem in the order the if expression is evaluated : if
> > wd is NULL and wd->m_id is evaluated first... Crash !
>
> [over the original code] :
>
> > > if (wd && (wd->m_id==id))
>
> I sincerely hope that is not the problem; it is very clearly defined in the
> C programming language that logical AND and OR operations proceed from left
> to right.
>
> -bp
> --
> B. James Phillippe . bryan@terran.org
> UNIX Software Engineer . http://www.terran.org/~bryan
> Member since 1.1.59 . finger:bryan@earth.terran.org
> MOTM: Waiting for the DSL to go in :/
>
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:25 ` B. James Phillippe
1998-11-13 21:48 ` Nicholas Sallembian
@ 1998-11-14 1:06 ` Bob McElrath
1998-11-14 13:20 ` sterwill
1 sibling, 1 reply; 15+ messages in thread
From: Bob McElrath @ 1998-11-14 1:06 UTC (permalink / raw)
To: axp-list
On Fri, 13 Nov 1998, B. James Phillippe wrote:
> On Fri, 13 Nov 1998, Nicholas Sallembian wrote:
>
> > Try this code :
> ...
> > if (wd)
> > if (wd->m_id==id)
> ...
> > There might be a problem in the order the if expression is evaluated : if
> > wd is NULL and wd->m_id is evaluated first... Crash !
>
> [over the original code] :
>
> > > if (wd && (wd->m_id==id))
>
> I sincerely hope that is not the problem; it is very clearly defined in the
> C programming language that logical AND and OR operations proceed from left
> to right.
It is, of course possible that the pointer wd has a non-zero value, but
points to memory not owned by the process...that would still cause a seg
fault, and would have been evaluated properly...
-- Bob
./'^`\._./'~`\._./'~`\._./'~`\._./'#`\._./'~`\._./'~`\._./'~`\._./'^`\.
/ Rube Goldberg? Bah! Amateur! I give you..Windows 98! Linux everywhere \
| Linux, because everyone's work is mission critical. ANYTHING inside. |
|_Bob McElrath (mcelrath@wisconsin.cern.ch) Univ. of Wisconsin at Madison_|
\.___________________________________________________________________./
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-14 1:06 ` Bob McElrath
@ 1998-11-14 13:20 ` sterwill
1998-11-14 17:37 ` Brian E.W. Wood
0 siblings, 1 reply; 15+ messages in thread
From: sterwill @ 1998-11-14 13:20 UTC (permalink / raw)
To: axp-list
> On Fri, 13 Nov 1998, B. James Phillippe wrote:
> > [over the original code] :
> >
> > > > if (wd && (wd->m_id==id))
> >
> > I sincerely hope that is not the problem; it is very clearly defined in the
> > C programming language that logical AND and OR operations proceed from left
> > to right.
>
> It is, of course possible that the pointer wd has a non-zero value, but
> points to memory not owned by the process...that would still cause a seg
> fault, and would have been evaluated properly...
Well, as part of the AbiWord team, I can assure you that we're doing many
such assignment tests in the code (not good news, huh? :). In fact, the new
toolbar framework is similar to the implementation of the menu layout framework.
In short, this looks like a compiler issue on the Alpha, but without access to an
Alpha (which I may have shortly if I buy one) it's hard to tell. It's
a very legal C++ test; I'm using EGCS 1.1b with -Wall and often -pedantic
to keep out "that which is not ANSI," but on an Intel, which is all we
have available now.
You know, this may be completely off here, but I'm wondering if the "&&"
is somehow not correct in ANDing the result of (wd->m_id == id) on a
platform where the size of "wd" (pointer) is not the same size as
"(wd->m_id == id)" (bool same as int which is != size of pointer?). Wild
guess here. :) I would assume this possibility is very remote
since the evaluation is essentially "if(wd){if(wd->m_id==id) {} }", but
I haven't looked at the compiler source; it may be optimizing something
funny.
--
Shaw Terwilliger (twig@advancenet.net | sterwill@abisource.com)
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: Any C++ on Alpha gfurus out there?
1998-11-14 13:20 ` sterwill
@ 1998-11-14 17:37 ` Brian E.W. Wood
0 siblings, 0 replies; 15+ messages in thread
From: Brian E.W. Wood @ 1998-11-14 17:37 UTC (permalink / raw)
To: axp-list
On 14-Nov-98 sterwill@io.nu wrote:
>
> Well, as part of the AbiWord team, I can assure you that we're doing many
> such assignment tests in the code (not good news, huh? :). In fact, the new
> toolbar framework is similar to the implementation of the menu layout
> framework.
> In short, this looks like a compiler issue on the Alpha, but without access
> to an
> Alpha (which I may have shortly if I buy one) it's hard to tell. It's
> a very legal C++ test; I'm using EGCS 1.1b with -Wall and often -pedantic
> to keep out "that which is not ANSI," but on an Intel, which is all we
> have available now.
First, much thanks to all who responded to my question. My main point is that
the code *does* run on an Intel machine but not on (at least my) Alpha, so this
list seemed an appropriate place to ask.
>
> You know, this may be completely off here, but I'm wondering if the "&&"
> is somehow not correct in ANDing the result of (wd->m_id == id) on a
> platform where the size of "wd" (pointer) is not the same size as
> "(wd->m_id == id)" (bool same as int which is != size of pointer?). Wild
> guess here. :) I would assume this possibility is very remote
> since the evaluation is essentially "if(wd){if(wd->m_id==id) {} }", but
> I haven't looked at the compiler source; it may be optimizing something
> funny.
Most problems where code runs on an Intel and not on an Alpha seem to be
related to the pointer/integer size difference so what you say may make sense.
I'm considering dropping back from egcs 1.1b to 1.0.3a to see what happens. As
you know the code is already being compiled with no optimizations.
Heinz Ulrich Stille asked whether callback_action was 32 or 64 bit, I'm not
enough of a programmer to know the answer to this.
The lack of a decent WP for the alpha platform has been a real bugaboo for me,
so I'd really like to see this problem resolved, any additional alpha-guru
suggestions are always appreciated.
---
Brian E.W. Wood beww@intac.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:17 ` Nicholas Sallembian
1998-11-13 19:25 ` B. James Phillippe
@ 1998-11-13 19:26 ` Anders Hammarquist
1 sibling, 0 replies; 15+ messages in thread
From: Anders Hammarquist @ 1998-11-13 19:26 UTC (permalink / raw)
To: axp-list
> Try this code :
>
> const char * EV_UnixMenu::_getItemPath(AP_Menu_Id id) const
> {
> for (UT_uint32 k=0; (k < m_nrActualFactoryItems); k++)
> {
> _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
> if (wd)
> if (wd->m_id==id)
> return m_menuFactoryItems[k].path;
> }
>
> There might be a problem in the order the if expression is evaluated : if wd is
> NULL and wd->m_id is evaluated first... Crash !
If this code works and the other doesn't you've found a compiler bug. && is
supposed to evaluate left to right (lazily, so that it stops when it knows the
outcome).
/Anders
--
-- Of course I'm crazy, but that doesn't mean I'm wrong.
Anders Hammarquist | iko@cd.chalmers.se
Not system administrator at DjungelData | Hem: +46 31 47 69 27
Chalmers University of Technology, G|teborg, Sweden | Mob: +46 707 27 86 87
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:10 Any C++ on Alpha gfurus out there? Brian E.W. Wood
1998-11-13 19:17 ` Nicholas Sallembian
@ 1998-11-13 19:37 ` Heinz Ulrich Stille
1998-11-16 3:50 ` Michael J. Donahue
1998-11-16 13:15 ` Stefan Schroepfer
2 siblings, 1 reply; 15+ messages in thread
From: Heinz Ulrich Stille @ 1998-11-13 19:37 UTC (permalink / raw)
To: axp-list
Hi!
On Fri, 13 Nov 1998, Brian E.W. Wood wrote:
> {
> _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
> if (wd && (wd->m_id==id))
> return m_menuFactoryItems[k].path;
> }
What type is callback_action? 32 or 64 bit?
MfG, Ulrich
--
Alone of all the creatures in the world, trolls believe that all living
things go through Time backwards. If the past is visible and the future is
hidden, they say, then it means you must be facing the wrong way. Everything
alive is going through life back to front.
T. Pratchett, "Reaper Man"
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:37 ` Heinz Ulrich Stille
@ 1998-11-16 3:50 ` Michael J. Donahue
0 siblings, 0 replies; 15+ messages in thread
From: Michael J. Donahue @ 1998-11-16 3:50 UTC (permalink / raw)
To: axp-list
Heinz Ulrich Stille <Heinz.Ulrich.Stille@mbi-os.de> writes:
>On Fri, 13 Nov 1998, Brian E.W. Wood wrote:
>> {
>> _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
>> if (wd && (wd->m_id==id))
>> return m_menuFactoryItems[k].path;
>> }
>
>What type is callback_action? 32 or 64 bit?
Ulrich's question is the first thing to check. Anyone with experience
porting 32-bit apps to the Alpha knows that pointer casts are red flags.
Easy thing to try: remove the pointer cast, i.e.,
_wd * wd = m_menuFactoryItems[k].callback_action;
and compile with -Wall. If callback_action is a void*, then you won't
need the cast. If not, then dimes to doughnuts it is a 32-bit int.
Passing a * through an 'int' works on a 32-bit OS (like Linux/x86), but
is sure to segfault on Linux/axp.
In any event, the compiler warning message should inform you what conversion
is going on here, without having to read through the code.
-m
--
Michael J. Donahue
National Institute of Standards and Technology
Mathematical & Computational Sciences Division
Bldg 820, Rm 365
Gaithersburg, MD 20899
email: michael.donahue@nist.gov
voice: (301) 975-5424
fax: (301) 990-4127
web: http://math.nist.gov/mcsd/Staff/MDonahue/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-13 19:10 Any C++ on Alpha gfurus out there? Brian E.W. Wood
1998-11-13 19:17 ` Nicholas Sallembian
1998-11-13 19:37 ` Heinz Ulrich Stille
@ 1998-11-16 13:15 ` Stefan Schroepfer
1998-11-16 13:45 ` Paul Tomblin
2 siblings, 1 reply; 15+ messages in thread
From: Stefan Schroepfer @ 1998-11-16 13:15 UTC (permalink / raw)
To: axp-list
Brian E.W. Wood wrote:
>
> _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
I'm definitely not a C++ guru, but please can someone
explain me
- Where is the l-value in that line? For what concept will
I have to search in Stroustroup (after I got mine back)?
- Why does one write such a counter-intuitive construct
even if it is a valid one?
Stefan Schroepfer
scr@iis.fhg.de
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-16 13:15 ` Stefan Schroepfer
@ 1998-11-16 13:45 ` Paul Tomblin
1998-11-16 14:24 ` Stefan Schroepfer
1998-11-16 14:43 ` Leo
0 siblings, 2 replies; 15+ messages in thread
From: Paul Tomblin @ 1998-11-16 13:45 UTC (permalink / raw)
To: axp-list
Quoting Stefan Schroepfer (scr@iis.fhg.de):
> Brian E.W. Wood wrote:
> >
> > _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
>
> I'm definitely not a C++ guru, but please can someone
> explain me
> - Where is the l-value in that line? For what concept will
> I have to search in Stroustroup (after I got mine back)?
> - Why does one write such a counter-intuitive construct
> even if it is a valid one?
What's so hard to understand? _wd is obviously a class or a typedef. wd is a
pointer to that class. m_menuFactoryItems is an array of structs or class
instances, which has a data field (or method) of type (pointer to _wd) called
callback_action.
If you find this counter-intuitive, you should stick to simple languages like
VB.
--
"Linux's homebase is currently commodity network and server infrastructure. By
folding extended functionality ... into today's commodity services, we raise
the bar & change the rules of the game."
- Microsoft leaks their strategy for monopolizing the Internet and the desktop.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-16 13:45 ` Paul Tomblin
@ 1998-11-16 14:24 ` Stefan Schroepfer
1998-11-16 14:43 ` Leo
1 sibling, 0 replies; 15+ messages in thread
From: Stefan Schroepfer @ 1998-11-16 14:24 UTC (permalink / raw)
To: axp-list
Paul Tomblin wrote:
>
> Quoting Stefan Schroepfer (scr@iis.fhg.de):
> > Brian E.W. Wood wrote:
> > >
> > > _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
> >
> > [...]
> > - Why does one write such a counter-intuitive construct
> > even if it is a valid one?
>
> What's so hard to understand? _wd is obviously a class or a typedef. wd is a
> pointer to that class. m_menuFactoryItems is an array of structs or class
> instances, which has a data field (or method) of type (pointer to _wd) called
> callback_action.
Thanks for the reply. I simply overlooked that there's an
instantiation of a (_wd *) in this line and got confused
about this presumed dammned _product_ on the left side of
the assignment (it's not my day today).
scr
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
1998-11-16 13:45 ` Paul Tomblin
1998-11-16 14:24 ` Stefan Schroepfer
@ 1998-11-16 14:43 ` Leo
1 sibling, 0 replies; 15+ messages in thread
From: Leo @ 1998-11-16 14:43 UTC (permalink / raw)
To: axp-list
Paul Tomblin wrote:
> Quoting Stefan Schroepfer (scr@iis.fhg.de):
> > Brian E.W. Wood wrote:
> > >
> > > _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
> >
> > I'm definitely not a C++ guru, but please can someone
> > explain me
> > - Where is the l-value in that line? For what concept will
> > I have to search in Stroustroup (after I got mine back)?
> > - Why does one write such a counter-intuitive construct
> > even if it is a valid one?
>
> What's so hard to understand? _wd is obviously a class or a typedef. wd is a
> pointer to that class. m_menuFactoryItems is an array of structs or class
> instances, which has a data field (or method) of type (pointer to _wd) called
> callback_action.
>
> If you find this counter-intuitive, you should stick to simple languages like
> VB.
>
What is hard to understand is the so l-value there; can't see any!?
I suppose the line should be:
(_wd *) wd = (_wd *)m_menuFactoryItems[k].callback_action;
If this is the case, there is no l-value here.
If you want this to compile, you should write:
(_wd * &) wd = (_wd *)m_menuFactoryItems[k].callback_action;
Now the l-value is the expression on the left of the = sign.
Under Stroustroup, You should look for l-value in the index, or the references
section, I guess.
Leo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Any C++ on Alpha gfurus out there?
@ 1998-11-16 14:49 Leo
0 siblings, 0 replies; 15+ messages in thread
From: Leo @ 1998-11-16 14:49 UTC (permalink / raw)
To: axp-list
Paul Tomblin wrote:
> >
> > Quoting Stefan Schroepfer (scr@iis.fhg.de):
> > > Brian E.W. Wood wrote:
> > > >
> > > > _wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
> > >
> > > [...]
> > > - Why does one write such a counter-intuitive construct
> > > even if it is a valid one?
> >
> > What's so hard to understand? _wd is obviously a class or a
typedef. wd is a
> > pointer to that class. m_menuFactoryItems is an array of structs or
class
> > instances, which has a data field (or method) of type (pointer to
_wd) called
> > callback_action.
> Thanks for the reply. I simply overlooked that there's an
> instantiation of a (_wd *) in this line and got confused
> about this presumed dammned _product_ on the left side of
> the assignment (it's not my day today).
>
> scr
Oops... that's true, the l-value is the wd variable, of course.
Sorry,
Leo
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~1998-11-16 14:51 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-11-13 19:10 Any C++ on Alpha gfurus out there? Brian E.W. Wood
1998-11-13 19:17 ` Nicholas Sallembian
1998-11-13 19:25 ` B. James Phillippe
1998-11-13 21:48 ` Nicholas Sallembian
1998-11-14 1:06 ` Bob McElrath
1998-11-14 13:20 ` sterwill
1998-11-14 17:37 ` Brian E.W. Wood
1998-11-13 19:26 ` Anders Hammarquist
1998-11-13 19:37 ` Heinz Ulrich Stille
1998-11-16 3:50 ` Michael J. Donahue
1998-11-16 13:15 ` Stefan Schroepfer
1998-11-16 13:45 ` Paul Tomblin
1998-11-16 14:24 ` Stefan Schroepfer
1998-11-16 14:43 ` Leo
-- strict thread matches above, loose matches on Subject: below --
1998-11-16 14:49 Leo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox