Board index » delphi » MCI programming: LOTS of general protection faults...

MCI programming: LOTS of general protection faults...

Hello to everyone.

I'm making a CD player using TPW1.5. I use MCI message-based interface to
send commands. But I have a problem:
I always receive "general protection fault" errors when I run those
commands. The program is correct, because the compilation does not return
any errors. Even if it were incorrect, I should receive MCI error codes
returned by mciSendCommand function, but I do not receive such errors, but
"general protection faults", so run-time errors!!!!

Does anyone can help me? Looking at the examples of other people, I
implemented a "variable cleaning" at the beginning of each function, like
that:

var
  Info : TMCI_Open_Parms;

begin
  FillChar (Info, SizeOf (TMCI_Open_Parms), #0);
  [...]
end;

but the problem persists. Please help me, if you can! If you put my e-mail
address in the Cc: field of the reply (mauro...@tin.it), I'll be grateful.
Thank you!

--
Mauro Molinari
Internet e-mail: mauro...@mbox.vol.it / mauro...@tin.it

 

Re:MCI programming: LOTS of general protection faults...


Quote
Mauro Molinari wrote:

> Hello to everyone.

> I'm making a CD player using TPW1.5. I use MCI message-based interface to
> send commands. But I have a problem:
> I always receive "general protection fault" errors when I run those
> commands. The program is correct, because the compilation does not return
> any errors. Even if it were incorrect, I should receive MCI error codes

Sorry, this only means that your syntax is correct, not that the program
will work correctly (pointer operations are a 'nice' example)

Quote
> returned by mciSendCommand function, but I do not receive such errors, but
> "general protection faults", so run-time errors!!!!

Errors returned by mciSendCommand are like saying: 'you gave me invalid info,
this is what is wrong'. Still, mciSendCommand can read the info. GPF's are
a different type of error: illegal memory access, so run-time errors before
mciSendCommand can respond.

Quote
> Does anyone can help me? Looking at the examples of other people, I
> implemented a "variable cleaning" at the beginning of each function, like
> that:

> var
>   Info : TMCI_Open_Parms;

> begin
>   FillChar (Info, SizeOf (TMCI_Open_Parms), #0);
>   [...]
> end;

> but the problem persists. Please help me, if you can! If you put my e-mail
> address in the Cc: field of the reply (mauro...@tin.it), I'll be grateful.
> Thank you!

Sounds like you have forgotten to initialise pointers somewhere:
in general GPF's mean that a routine is trying to read from or
write to a part of memory where it has no rights. A _very_ common
cause for this (at least for me :) is forgetting to initialise
a pointer variable (this can be a pointer to e.g. a string within
an otherwise correct data record).

In the example you gave, there are 3 pChar fields within the record,
that all get initialised to NIL in your routine. At least two of these
appear to be required parameters. And dereferencing a NIL pointer
gives you a GPF.

Hope this helps,

Remco

By the way, in general 1 posting is enough to get an answer. No need
to repeat yourself.
--
Remco Vietor                            Department of Chemistry
re...@chem.gla.ac.uk                       J. Black Building
                                        University of Glasgow
                                        Glasgow G12 8QQ
                                        U.K.

Other Threads