View Issue Details

IDProjectCategoryView StatusLast Update
0001023JEDI VCL00 JVCL Componentspublic2004-01-29 10:35
ReporterckinAssigned Toobones 
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001023: Nullpointer exception in jvcl200_d70
DescriptionAfter a new installation of Delphi Professional 7 (Build 4.453) and installion JEDI I got a nullpointer exception in jvcl200_d70. I'm using Windows XP. On a identically installed W2K Machine it works without this error. I'm using JEDI 2.10 stable with updates.

I located the problem in jclsysinfo at the line with CpuInfo.MMX and replaced it with old jvcl code. Now it seems to work without the null pointer exception.


procedure GetCpuInfo(var CpuInfo: TCpuInfo);
begin
  CpuInfo := CPUID;
  CpuInfo.IsFDIVOK := TestFDIVInstruction;
  if CpuInfo.HasInstruction then
  begin
    if (CpuInfo.Features and TSC_FLAG) = TSC_FLAG then
      GetCpuSpeed(CpuInfo.FrequencyInfo);

    //Replaced because of WinXP Error
    if (CpuInfo.Features and MMX_FLAG) = MMX_FLAG then
      CpuInfo.MMX := True
    else
      CpuInfo.MMX := False;
    //Original only this line
// CpuInfo.MMX := (CpuInfo.Features and MMX_FLAG) = MMX_FLAG;
  end;
end;
Additional InformationAfter the first installation everything works fine when starting delphi. After the second start of Delphi the error occurs everythime.
TagsNo tags attached.

Relationships

has duplicate 0001167 closedRobert Rossmair JEDI Code Library EZeroDivide is raised in GetCPUSpeed 
has duplicate 0001074 closedRobert Rossmair JEDI Code Library Dr. Watson when GetCPUInfo is called 
has duplicate 0001112 closedRobert Rossmair JEDI Code Library Linking JclGraphUtils GPFs under XP Home Edition 
has duplicate 0001285 closedremkobonte JEDI VCL AV on startup 
has duplicate 0001286 closedremkobonte JEDI VCL division by zero on fast machines 
has duplicate 0001288 closedremkobonte JEDI VCL EZeroDivide in JclSysinfo 
has duplicate 0001295 closedRobert Rossmair JEDI Code Library DevideByZero Error 
has duplicate 0001334 closedremkobonte JEDI VCL TJvTrayIcon; TJvFormPlacement imcompatible with approx 10% of Win XP machines 

Activities

ckin

2003-07-07 06:18

reporter   ~0002306

The error seems to be more realated to cpu processor than to windows. It appears on a Pentium 4 HT 2,6 GHz.

ckin

2003-07-07 07:01

reporter   ~0002307

The jvcl code replacement had no use, the error still occurs. Installing JclSysInfo BugFix attached to Bug 0000401 doesn't work either.
At starting Delphi 7 (german version) there appears always the error: "Package c:ProgrammeBorlandDelphi7ProjectsBplJVCL200_D70.bpl cannot be loaded. Division by zero. Do you want to load this package at the next project?"

obones

2003-07-07 18:24

administrator   ~0002313

I'm quite glad you noticed your replacement was no use, it does in 4 lines what was done in one...
However, as not much of us have access to a P4HT, I'd like you to help us track that one.
The null pointer exception might come from the fact the CpuInfo is not initialized (or CPUID is null). So if you could examine the value of CpuInfo when the error is coming in debug mode, that would be helpful. Also, could you give us a dump of the call stack at the moment of the call (view, debug windows, call stack).

ckin

2003-07-08 06:05

reporter   ~0002314

Everytime at startup appears the message "Package c:ProgrammeBorlandDelphi7ProjectsBplJVCL200_D70.bpl cannot be loaded. Division by zero. Do you want to load this package at the next project?"
Only sometimes the runtime error message 'runtime error 216 at 00404316' appears when starting an application within the Delphi IDE. The following information I could extract for you:


Stack:
======
GetCpuInfo(???)
SetupFunctions
JclGraphUtils

Debug:
======
MMX_FLAG value is 8388608
TSC_FLAG value is 16
CpuInfo value is not defined

Event protocol (translated from german):
================
First random-exception at $77E53887. Exception-class EZeroDivide with message 'division by zero'


Compiler stops at line 2206 in jvclinfo 'CpuInfo.MMX := (CpuInfo.Features and MMX_FLAG) = MMX_FLAG;'

ckin

2003-07-14 11:49

reporter   ~0002337

Last edited: 2003-07-14 22:33

Outside the Delphi IDE there is no way to start the compiled application. There appears everytime "Runtime error 216 at 00404316" and then the application finishes. So this seems to be a quite severe bug of the version 2.1 for the intel pentium 4 ht processors.
Fortunately the JEDI VCL version 2.0 works without this bug.

edited on: 07-14 22:33

edited on: 07-14 22:33

obones

2003-07-17 21:23

administrator   ~0002349

So you say that version 2.0 is working ?

In this case, can you give me the exact code of the CPUID function (it is pure assembly), and the GetCPUInfo procedure ?
I'll then be able to look at the differences and let you know what's wrong.
Thanks for your patience

ckin

2003-07-29 02:36

reporter   ~0002382

Sorry for the late reply.

I use now the JVCL 2.0 Full Install from the download page: JCL122+JVCL200FinalFullInstall.zip

With the following files of the 2.1 Version I got the errors:
Full Install JCL+JVCL210FullInstall.zip

Also tried the following bug fixes which didn't solve the problem:
0000401-JclSysInfo.zip
JVCL210FIX030313.zip
JvInterpreterUpdateTo2_10.zip

obones

2003-08-22 04:42

administrator   ~0002446

Hi
Sorry for the delay, but it's very hard to reproduce a bug without having the hardware causing it at hand.
Peter suggested you try to replace the GetCPUSpeed function in JclSysInfo.pas with the one below. Please let us know if that fixes the problem.
Thanks for your patience


function GetCPUSpeed(var CpuSpeed: TFreqInfo): Boolean;
var
  T0, T1: TULargeInteger;
  CountFreq: TULargeInteger;
  Freq, Freq2, Freq3, Total: Integer;
  TotalCycles, Cycles: Int64;
  Stamp0, Stamp1: Int64;
  TotalTicks, Ticks: Cardinal;
  Tries, Priority: Integer;
  Thread: THandle;
begin
  Stamp0 := 0;
  Stamp1 := 0;
  Freq := 0;
  Freq2 := 0;
  Freq3 := 0;
  Tries := 0;
  TotalCycles := 0;
  TotalTicks := 0;
  Total := 0;

  Thread := GetCurrentThread();
  Result := QueryPerformanceFrequency(Int64(CountFreq));
  if Result then
  begin
    while ((Tries < 3 ) or ((Tries < 20) and ((Abs(3 * Freq - Total) > 3) or
      (Abs(3 * Freq2 - Total) > 3) or (Abs(3 * Freq3 - Total) > 3)))) do
    begin
      Inc(Tries);
      Freq3 := Freq2;
      Freq2 := Freq;
      QueryPerformanceCounter(Int64(T0));
      T1.LowPart := T0.LowPart;
      T1.HighPart := T0.HighPart;

      Priority := GetThreadPriority(Thread);
      if Priority <> THREAD_PRIORITY_ERROR_RETURN then
        SetThreadPriority(Thread, THREAD_PRIORITY_TIME_CRITICAL);
      try
        while (T1.LowPart - T0.LowPart) < 50 do
        begin
          QueryPerformanceCounter(Int64(T1));
          Stamp0 := ReadTimeStampCounter;
        end;
        T0.LowPart := T1.LowPart;
        T0.HighPart := T1.HighPart;

        while (T1.LowPart - T0.LowPart) < 1000 do
        begin
          QueryPerformanceCounter(Int64(T1));
          Stamp1 := ReadTimeStampCounter;
        end;
      finally
        if Priority <> THREAD_PRIORITY_ERROR_RETURN then
          SetThreadPriority(Thread, Priority);
      end;

      Cycles := Stamp1 - Stamp0;
      Ticks := T1.LowPart - T0.LowPart;
      Ticks := Ticks * 100000;
      if CountFreq.LowPart <> 0 then
        Ticks := Round(Ticks / (CountFreq.LowPart / 10))
      else
        Ticks := 0;
      TotalTicks := TotalTicks + Ticks;
      TotalCycles := TotalCycles + Cycles;
      if Ticks <> 0 then
        Freq := Round(Cycles / Ticks)
      else
        Freq := 0;
      Total := Freq + Freq2 + Freq3;
    end;
    if TotalTicks <> 0 then
    begin
      Freq3 := Round((TotalCycles * 10) / TotalTicks);
      Freq2 := Round((TotalCycles * 100) / TotalTicks);
    end
    else
    begin
      Freq3 := 0;
      Freq2 := 0;
    end;

    if Freq2 - (Freq3 * 10) >= 6 then
      Inc(Freq3);
    if TotalTicks <> 0 then
      CpuSpeed.RawFreq := Round(TotalCycles / TotalTicks)
    else
      CpuSpeed.RawFreq := 0;
    CpuSpeed.NormFreq := CpuSpeed.RawFreq;

    Freq := CpuSpeed.RawFreq * 10;
    if (Freq3 - Freq) >= 6 then
      Inc(CpuSpeed.NormFreq);

    CpuSpeed.ExTicks := TotalTicks;
    CpuSpeed.InCycles := TotalCycles;

    CpuSpeed.NormFreq := RoundFrequency(CpuSpeed.NormFreq);
    Result := True;
  end;
end;

lmusi

2003-09-10 06:37

reporter   ~0002504

Hi,
I've got the same error message after installing JVCL210 : 'Package c:Program FilesBorlandDelphi7ProjectsBplJVCL200_D70.bpl cannot be loaded. Division by zero. Do you want to load this package at the next project?'.
I've a Dell Workstation 450 with Dual Cpu XEON HT 2.4 Ghz with XP Pro SP1.
If I write a little app that invoke GetCpuInfo from jclSysInfo all work fine without any error.
How can investigate further this problem ?
On my notebook P4 with XP SP1 the installation of JVCL is working fine and the package is correctly loaded by D7 at startup.
Thank you for your attention.

remkobonte

2003-09-10 14:28

developer   ~0002505

Please check 0000401 and apply the fix for JclSysInfo.pas.

Let us know if it makes any difference.

lmusi

2003-09-16 03:37

reporter   ~0002513

I've applied the fix for JclSysInfo.pas related to bug 0000401.
I've forced a complete build of the 2 Packages JVCL200_X70 without problem.
When I've tried to install del Design time package i've received an exception of 'Divide by 0'.
How can I do to resolve this problem ?
Thanks

Wabit

2003-10-29 07:04

reporter   ~0002652

I can also reproduce this problem on my hyperthreading machine. I will dig into the subject, if anyone have work in progress please contact me. I know of at least one benchmark application that report my CPU speed as negative, so it gotta be a HT problem

remkobonte

2003-10-31 14:41

developer   ~0002657

Wabit (and others that have this problem and want to work on it), please post a message on the JVCL newsgroup at:

news://forums.talkto.net/jedi.vcl

or

news://forums.talkto.net/jedi.jcl

so we can send you test projects. (No JVCL/JCL developer has a hyperthreading machine so we can't test it)

You can also contact me directly at: remkobonte at myrealbox dot com

obones

2003-12-27 03:37

administrator   ~0002778

The latest JCL source code has been posted to CVS and jedi.binaries on forums.talkto.net
Please use that code, it won't generate Exceptions

Issue History

Date Modified Username Field Change
2004-01-24 18:30 Robert Rossmair Relationship added has duplicate 0001112
2004-01-29 10:35 user72 Status resolved => closed
2004-02-17 10:27 remkobonte Relationship added has duplicate 0001334