comp.lang.ada
 help / color / mirror / Atom feed
* Constraint Error. Why?
@ 1999-01-12  0:00 Roga Danar
  1999-01-14  0:00 ` Corey Ashford
  0 siblings, 1 reply; 4+ messages in thread
From: Roga Danar @ 1999-01-12  0:00 UTC (permalink / raw)


The following code was compiled with Rational Apex Ada95 on WinNT.

 Before you ask.  Yes, I have run it through the debugger but it has been no
help
at all.  It just tell me:
*****************************************
"Handle
=> Could not find start address of "x25.write_to_port".
=>
Cannot find frame for "x25.write_to_port" on call stack."

********************************************

Okay then.  Why am I getting a contraint error when I check for null first?

Thanks in advance.

Code for the subroutine exactly as it is:

    function Write_To_Port return Boolean is

        --Host_Name

        -- Port_Name : constant String :=
        X25 : constant String := "\\\\GATEWAY_PC_15\\lcp1";
        Com2 : constant String := "Com2";
        Com3 : constant String := "Com3";
        Com4 : constant String := "Com4";

        Handle : Windows.Handle := null;

        Null_Handle : Windows.Pvoid := null;
        Null_Void : Windows.Void := null;

        function "=" (L, R : Windows.Pvoid) return Boolean renames Windows."=";
        function "=" (L, R : Windows.Void) return Boolean renames Windows."=";

        Status : Boolean := False;

    begin


        Win_Show.Display ("Creating the file named: " & Com2);

        Handle := Winbase.Createfile (
                                      Com2,
                                      V_Bits.Bit_Or
                                         (Windows.Generic_Read,
                                          Windows.Generic_Write),
                                      0,
                                      null,
                                      Winbase.Open_Existing,
                                      Winbase.File_Flag_Overlapped,
                                      null);

--** Constriant Error on this line **
        if Handle /= null and then Handle.all /= null then
--
            if Handle.all.all /= Winbase.Invalid_Handle_Value then
                Win_Show.Display ("Created file !!");
                Status := True;
            end if;
        end if;

        return Status;

    exception
        when E: others =>
            Win_Show.Display
               (" ** Somethin' BAD happened processing " & Com2 & " ** " &
                Aen (E));

    end Write_To_Port;
--







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Constraint Error. Why?
  1999-01-12  0:00 Constraint Error. Why? Roga Danar
@ 1999-01-14  0:00 ` Corey Ashford
  1999-01-14  0:00   ` Roga Danar
  0 siblings, 1 reply; 4+ messages in thread
From: Corey Ashford @ 1999-01-14  0:00 UTC (permalink / raw)


Assuming you purchased Apex, you ought to contact Rational's technical
support
with the problem(s) you are having with the product.  I'd suggest
sending
mail to support@rational.com.

You might want to double check that the constraint_error is coming from
that
"if" statement instead of, say, the previous call to Winbase.Createfile.

If it is the "if" statement, then I don't know what the problem is.  The
source
code looks correct.  If you are x86 assembler savvy, you might want to
look at
the disassembly of the "if" statement in the debugger to see if you can
tell
what's going wrong.

Roga Danar wrote:
> 
> The following code was compiled with Rational Apex Ada95 on WinNT.
> 
>  Before you ask.  Yes, I have run it through the debugger but it has been no
> help
> at all.  It just tell me:
> *****************************************
> "Handle
> => Could not find start address of "x25.write_to_port".
> =>
> Cannot find frame for "x25.write_to_port" on call stack."
> 
> ********************************************
[code deleted because my news server won't let post with so many quoted
lines]




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Constraint Error. Why?
  1999-01-14  0:00 ` Corey Ashford
@ 1999-01-14  0:00   ` Roga Danar
  1999-01-15  0:00     ` Corey Ashford
  0 siblings, 1 reply; 4+ messages in thread
From: Roga Danar @ 1999-01-14  0:00 UTC (permalink / raw)
  To: Corey Ashford

Thanks for your reply.  I have fixed the problem by looking at an older example of
code of I had a similiar problem.

The exception *is* coming from the "if" statement and not the Createfile call.

Handle is an access to an access to an integer.

What (appearently) is happening here is that the pointer is NOT NULL when it is
check by the "if" statement but pointing to anything which I can validly
deference.

The problem is easily solved with a call to a function which converts the HANDLE
to an integer which I can then check against the "Invalid_Handle_Value".

Michael

Corey Ashford wrote:

> Assuming you purchased Apex, you ought to contact Rational's technical
> support
> with the problem(s) you are having with the product.  I'd suggest
> sending
> mail to support@rational.com.

I *have* been working with Rational for weeks now on problem like this one. Thanks
though.

>
>
> You might want to double check that the constraint_error is coming from
> that
> "if" statement instead of, say, the previous call to Winbase.Createfile.
>
> If it is the "if" statement, then I don't know what the problem is.  The
> source
> code looks correct.  If you are x86 assembler savvy, you might want to
> look at
> the disassembly of the "if" statement in the debugger to see if you can
> tell
> what's going wrong.
>
> Roga Danar wrote:
> >
> > The following code was compiled with Rational Apex Ada95 on WinNT.
> >
> >  Before you ask.  Yes, I have run it through the debugger but it has been no
> > help
> > at all.  It just tell me:
> > *****************************************
> > "Handle
> > => Could not find start address of "x25.write_to_port".
> > =>
> > Cannot find frame for "x25.write_to_port" on call stack."
> >
> > ********************************************
> [code deleted because my news server won't let post with so many quoted
> lines]

--







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Constraint Error. Why?
  1999-01-14  0:00   ` Roga Danar
@ 1999-01-15  0:00     ` Corey Ashford
  0 siblings, 0 replies; 4+ messages in thread
From: Corey Ashford @ 1999-01-15  0:00 UTC (permalink / raw)


Roga Danar wrote:
> 
> Thanks for your reply.  I have fixed the problem by looking at an older example of
> code of I had a similiar problem.
> 
> The exception *is* coming from the "if" statement and not the Createfile call.
> 
> Handle is an access to an access to an integer.
> 
> What (appearently) is happening here is that the pointer is NOT NULL when it is
> check by the "if" statement but pointing to anything which I can validly
> deference.

It could be that "seg faults" are converted to constraint_errors within the Ada
runtime.  It's odd though.  Usually, if that is done at all, they are converted
to storage_errors.


> 
> The problem is easily solved with a call to a function which converts the HANDLE
> to an integer which I can then check against the "Invalid_Handle_Value".
> 

Glad you found a fix.

- Corey




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-01-15  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-12  0:00 Constraint Error. Why? Roga Danar
1999-01-14  0:00 ` Corey Ashford
1999-01-14  0:00   ` Roga Danar
1999-01-15  0:00     ` Corey Ashford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox