NO

Author Topic: Bug  (Read 2115 times)

Grincheux

  • Guest
Bug
« on: July 21, 2020, 01:59:40 PM »
When I compile using Debug minimize size that's OK
When I compile using maximize speed (always in debug mode) the result is wrong.
See colums header.
If I compile in release, all is wrong too...








Code: [Select]
static void Wnd01_OnCreate(HWND __hWnd)
{
alignas(HANDLE) LVCOLUMNA _Lvc ;
alignas(HANDLE) WORKDATAS _Work ;
alignas(HANDLE) LPSTR _lpszTmp ;


alignas(int) char _szTmp[1024] ;


    hListView_w1 = CreateWindowExA(WS_EX_CLIENTEDGE,WC_LISTVIEW,"",
WS_CHILD|WS_VISIBLE|WS_VSCROLL|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_SINGLESEL|LVS_SORTASCENDING,
0,0,0,0,__hWnd,NULL,hInstance,NULL) ;


ListView_SetExtendedListViewStyle(hListView_w1,LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES) ;
SendMessage(hListView_w1,WM_SETFONT,(WPARAM) hMainFont,TRUE) ;


ZeroMemory(&_Lvc,sizeof(LVCOLUMNA)) ;
_lpszTmp = _szTmp ;


_Lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_FMT ;
_Lvc.fmt = LVCFMT_CENTER ;
_Lvc.cx = 80 ;
_Lvc.pszText = "SPK-ID" ;


ListView_InsertColumn(hListView_w1,0,&_Lvc) ;
ListView_InsertColumn(hListView_w1,1,&_Lvc) ;


_Lvc.cx = 140 ;
_Lvc.pszText = _szTmp ;
Message_Get(24,_lpszTmp,sizeof(_szTmp)) ;

ListView_InsertColumn(hListView_w1,2,&_Lvc) ;


_Lvc.cx = 70 ;
_Lvc.pszText = "ACP" ;


ListView_InsertColumn(hListView_w1,3,&_Lvc) ;


_Lvc.cx = 60 ;
_Lvc.pszText = "OVE" ;


ListView_InsertColumn(hListView_w1,4,&_Lvc) ;


_Lvc.cx = 50 ;
Message_Get(25,_lpszTmp,sizeof(_szTmp)) ;
_Lvc.pszText = _szTmp ;


ListView_InsertColumn(hListView_w1,5,&_Lvc) ;


_Lvc.cx = 40 ;
_Lvc.pszText = "NEA" ;


ListView_InsertColumn(hListView_w1,6,&_Lvc) ;


_Lvc.pszText = "PHA" ;


ListView_InsertColumn(hListView_w1,7,&_Lvc) ;


// e, a, q, i, om, w, ma, ad, n, per, per_y, moid, class


// e = Eccentricity
// a = Semi-major axis (au)
// q =
// i = Inclination of orbit plane (DEG)
// om = Longitude of Ascending Node (DEG)
// w = Argument of Perihelion (DEG)
// ma = Mean anomaly (DEG)
// ad = Aphelion distance (au)
// n = Mean motion (DEG/DAY)
// per = Orbital period (DAYS)
// per_y = Orbital period (YRS)
// moid = Distance minimale d'intersection d'une orbite
// class = Classe d'orbite


_Lvc.fmt = LVCFMT_RIGHT ;
_Lvc.cx = 90 ;
_Lvc.pszText = "e" ;


ListView_InsertColumn(hListView_w1,8,&_Lvc) ;


_Lvc.pszText = "a" ;
_Lvc.cx = 135 ;


ListView_InsertColumn(hListView_w1,9,&_Lvc) ;


_Lvc.pszText = "q" ;


ListView_InsertColumn(hListView_w1,10,&_Lvc) ;


_Lvc.pszText = "i" ;
_Lvc.cx = 90 ;


ListView_InsertColumn(hListView_w1,11,&_Lvc) ;


_Lvc.pszText = "om" ;


ListView_InsertColumn(hListView_w1,12,&_Lvc) ;


_Lvc.pszText = "w" ;


ListView_InsertColumn(hListView_w1,13,&_Lvc) ;


_Lvc.pszText = "ma" ;


ListView_InsertColumn(hListView_w1,14,&_Lvc) ;


_Lvc.pszText = "ad" ;
_Lvc.cx = 135 ;


ListView_InsertColumn(hListView_w1,15,&_Lvc) ;


_Lvc.pszText = "n" ;
_Lvc.cx = 90 ;


ListView_InsertColumn(hListView_w1,16,&_Lvc) ;


_Lvc.pszText = "per_d" ;


ListView_InsertColumn(hListView_w1,17,&_Lvc) ;


_Lvc.pszText = "per_y" ;


ListView_InsertColumn(hListView_w1,18,&_Lvc) ;


_Lvc.pszText = "MOID" ;


ListView_InsertColumn(hListView_w1,19,&_Lvc) ;


ListView_DeleteColumn(hListView_w1,0) ;


// On affiche aussi bien les astéroïdes que les comètes et les planètes
// Au départ on affiche les asteroïdes sans différienciation Observer, Vectors et Elements
// On vérifie simplement que les fichiers existent


memset(&_Work,0,sizeof(WORKDATAS)) ;
sqlite3_exec(hWorkDataBase,szEmptyWorkTable,0,0,NULL) ;
sqlite3_exec(hWorkDataBase,"BEGIN TRANSACTION",0,0,NULL) ;
Filtre_000(__hWnd,&_Work) ;
sqlite3_exec(hWorkDataBase,"END TRANSACTION",0,0,NULL) ;
sqlite3_exec(hWorkDataBase,"VACUUM",0,0,NULL) ;


So I need help

Offline John Z

  • Member
  • *
  • Posts: 790
Re: Bug
« Reply #1 on: July 21, 2020, 04:50:27 PM »
Hi Grincheux,

Are you using RC3?  There was a bug fix in RC3 that fixed a optimize speed issue I ran into with prior release candidates.
Pelle also suggested that I try
#pragma pack_stack(off)
before the fix was implemented - maybe it will help your situation.

Hope this helps,
John Z

Grincheux

  • Guest
Re: Bug
« Reply #2 on: July 21, 2020, 05:33:37 PM »
I downloaded RC3 and applied  #pragma pack_stack(off) but the problem continue...
When I don't apply any optimisations it is good.
Thank You John
« Last Edit: July 21, 2020, 05:57:35 PM by Grincheux »

Offline John Z

  • Member
  • *
  • Posts: 790
Re: Bug
« Reply #3 on: July 22, 2020, 01:40:59 PM »
Hi Grincheux,

It does look like pointer confusion.  You might try adding a message box for troubleshooting like:

   _Lvc.cx = 40 ;
   _Lvc.pszText = "NEA" ;
MessageBoxA(__hWnd,_Lvc.pszText,"Should be NEA",MB_OK);
   ListView_InsertColumn(hListView_w1,6,&_Lvc) ;

Also you can insert #pragma optimize(none) just before "static void Wnd01_OnCreate(HWND __hWnd)"
to selectively turn off then
#pragma optimize(time) just after the procedure closing } to resume optimization - this is just to verify that the issue is totally within this procedure. Also gives a way to optimize everything else for speed while this procedure is not.

Another possibility would be to set the pointer _Lvc.pszText  to NULL between uses which may help the compiler de-confuse itself ……

On the code that was shown I did not see any thing that appeared to be a coding error.

Are you compiling with Level 2 warnings ? - you didn't show the top Compiler page options.

Of course this is all troubleshooting or avoidance -

Hope this can help, but I don't have the solution/answer....

John Z

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Bug
« Reply #4 on: July 22, 2020, 02:56:27 PM »
Try these *temporary* changes:

alignas(HANDLE) LVCOLUMNA _Lvc;  =>  volatile alignas(HANDLE) LVCOLUMNA _Lvc;  // Add volatile
ZeroMemory(&_Lvc, sizeof(LVCOLUMNA));  =>  ZeroMemory((void*)&_Lvc, sizeof(LVCOLUMNA));  // Add (void*) to cast away volatile complains (I think this is the only place...)

( A shortcut, trying to speed up the usage of alias information, misses some cases of &_Lvc -- drowning in a sea of casts to make Windows happy/me unhappy.)
/Pelle

Grincheux

  • Guest
Re: Bug
« Reply #5 on: July 22, 2020, 09:17:04 PM »
Thank Mr Pelle


I added your changes and it WORKS!
Code: [Select]
static void Wnd01_OnCreate(HWND __hWnd)
{
volatile alignas(HANDLE) LVCOLUMNA _Lvc ;
alignas(HANDLE) WORKDATAS _Work ;
alignas(HANDLE) LPSTR _lpszTmp ;


alignas(int) char _szTmp[1024] ;


    hListView_w1 = CreateWindowExA(WS_EX_CLIENTEDGE,WC_LISTVIEW,"",
WS_CHILD|WS_VISIBLE|WS_VSCROLL|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_SINGLESEL|LVS_SORTASCENDING,
0,0,0,0,__hWnd,NULL,hInstance,NULL) ;


ListView_SetExtendedListViewStyle(hListView_w1,LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES) ;
SendMessage(hListView_w1,WM_SETFONT,(WPARAM) hMainFont,TRUE) ;


ZeroMemory((void *) &_Lvc,sizeof(LVCOLUMNA)) ;
_lpszTmp = _szTmp ;


_Lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_FMT ;
_Lvc.fmt = LVCFMT_CENTER ;
_Lvc.cx = 80 ;
_Lvc.pszText = "SPK-ID" ;


ListView_InsertColumn(hListView_w1,0,&_Lvc) ;
ListView_InsertColumn(hListView_w1,1,&_Lvc) ;


_Lvc.cx = 140 ;
_Lvc.pszText = _szTmp ;
Message_Get(24,_lpszTmp,sizeof(_szTmp)) ;

ListView_InsertColumn(hListView_w1,2,&_Lvc) ;


_Lvc.cx = 70 ;
_Lvc.pszText = "ACP" ;


ListView_InsertColumn(hListView_w1,3,&_Lvc) ;


_Lvc.cx = 60 ;
_Lvc.pszText = "OVE" ;


ListView_InsertColumn(hListView_w1,4,&_Lvc) ;


_Lvc.cx = 50 ;
Message_Get(25,_lpszTmp,sizeof(_szTmp)) ;
_Lvc.pszText = _szTmp ;


ListView_InsertColumn(hListView_w1,5,&_Lvc) ;


_Lvc.cx = 40 ;
_Lvc.pszText = "NEA" ;


ListView_InsertColumn(hListView_w1,6,&_Lvc) ;


_Lvc.pszText = "PHA" ;


ListView_InsertColumn(hListView_w1,7,&_Lvc) ;


// e, a, q, i, om, w, ma, ad, n, per, per_y, moid, class


// e = Eccentricity
// a = Semi-major axis (au)
// q =
// i = Inclination of orbit plane (DEG)
// om = Longitude of Ascending Node (DEG)
// w = Argument of Perihelion (DEG)
// ma = Mean anomaly (DEG)
// ad = Aphelion distance (au)
// n = Mean motion (DEG/DAY)
// per = Orbital period (DAYS)
// per_y = Orbital period (YRS)
// moid = Distance minimale d'intersection d'une orbite
// class = Classe d'orbite


_Lvc.fmt = LVCFMT_RIGHT ;
_Lvc.cx = 90 ;
_Lvc.pszText = "e" ;


ListView_InsertColumn(hListView_w1,8,&_Lvc) ;


_Lvc.pszText = "a" ;
_Lvc.cx = 135 ;


ListView_InsertColumn(hListView_w1,9,&_Lvc) ;


_Lvc.pszText = "q" ;


ListView_InsertColumn(hListView_w1,10,&_Lvc) ;


_Lvc.pszText = "i" ;
_Lvc.cx = 90 ;


ListView_InsertColumn(hListView_w1,11,&_Lvc) ;


_Lvc.pszText = "om" ;


ListView_InsertColumn(hListView_w1,12,&_Lvc) ;


_Lvc.pszText = "w" ;


ListView_InsertColumn(hListView_w1,13,&_Lvc) ;


_Lvc.pszText = "ma" ;


ListView_InsertColumn(hListView_w1,14,&_Lvc) ;


_Lvc.pszText = "ad" ;
_Lvc.cx = 135 ;


ListView_InsertColumn(hListView_w1,15,&_Lvc) ;


_Lvc.pszText = "n" ;
_Lvc.cx = 90 ;


ListView_InsertColumn(hListView_w1,16,&_Lvc) ;


_Lvc.pszText = "per_d" ;


ListView_InsertColumn(hListView_w1,17,&_Lvc) ;


_Lvc.pszText = "per_y" ;


ListView_InsertColumn(hListView_w1,18,&_Lvc) ;


_Lvc.pszText = "MOID" ;


ListView_InsertColumn(hListView_w1,19,&_Lvc) ;


ListView_DeleteColumn(hListView_w1,0) ;


// On affiche aussi bien les astéroïdes que les comètes et les planètes
// Au départ on affiche les asteroïdes sans différienciation Observer, Vectors et Elements
// On vérifie simplement que les fichiers existent


memset(&_Work,0,sizeof(WORKDATAS)) ;


sqlite3_exec(hWorkDataBase,szEmptyWorkTable,0,0,NULL) ;
sqlite3_exec(hWorkDataBase,"BEGIN TRANSACTION",0,0,NULL) ;
Filtre_000(__hWnd,&_Work) ;
sqlite3_exec(hWorkDataBase,"END TRANSACTION",0,0,NULL) ;
sqlite3_exec(hWorkDataBase,"VACUUM",0,0,NULL) ;


return ;
}


Building Chloe.obj.
Building Chloe.res.
Building Filtres.obj.
Building Language.obj.
Building Log.obj.
Building Orbites.obj.
Building Utilities.obj.
Building Window-01.obj.
Building Window-02.obj.
Building Window-03.obj.
Building Window-04.obj.
Building Window-05.obj.
Building Chloe.exe.
POLINK: warning: Realigned section '.idata$5' in object 'sqlite3.lib(sqlite3.dll)' (from 4 to 8 byte(s)).
POLINK: warning: Realigned section '.idata$4' in object 'sqlite3.lib(sqlite3.dll)' (from 4 to 8 byte(s)).
POLINK: warning: Realigned section '.idata$2' in object 'libgfl.lib(libgfl340.dll)' (from 4 to 1 byte(s)).
Done.

Grincheux

  • Guest
Re: Bug
« Reply #6 on: July 22, 2020, 09:19:38 PM »

Thank Mr Pelle




I added your changes and it WORKS!
Code: [Select]
static void Wnd01_OnCreate(HWND __hWnd)
{
volatile alignas(HANDLE) LVCOLUMNA _Lvc ;
alignas(HANDLE) WORKDATAS _Work ;
alignas(HANDLE) LPSTR _lpszTmp ;


alignas(int) char _szTmp[1024] ;


    hListView_w1 = CreateWindowExA(WS_EX_CLIENTEDGE,WC_LISTVIEW,"",
WS_CHILD|WS_VISIBLE|WS_VSCROLL|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_SINGLESEL|LVS_SORTASCENDING,
0,0,0,0,__hWnd,NULL,hInstance,NULL) ;


ListView_SetExtendedListViewStyle(hListView_w1,LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES) ;
SendMessage(hListView_w1,WM_SETFONT,(WPARAM) hMainFont,TRUE) ;


ZeroMemory((void *) &_Lvc,sizeof(LVCOLUMNA)) ;
_lpszTmp = _szTmp ;


_Lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_FMT ;
_Lvc.fmt = LVCFMT_CENTER ;
_Lvc.cx = 80 ;
_Lvc.pszText = "SPK-ID" ;


ListView_InsertColumn(hListView_w1,0,&_Lvc) ;
ListView_InsertColumn(hListView_w1,1,&_Lvc) ;


_Lvc.cx = 140 ;
_Lvc.pszText = _szTmp ;
Message_Get(24,_lpszTmp,sizeof(_szTmp)) ;

ListView_InsertColumn(hListView_w1,2,&_Lvc) ;


_Lvc.cx = 70 ;
_Lvc.pszText = "ACP" ;


ListView_InsertColumn(hListView_w1,3,&_Lvc) ;


_Lvc.cx = 60 ;
_Lvc.pszText = "OVE" ;


ListView_InsertColumn(hListView_w1,4,&_Lvc) ;


_Lvc.cx = 50 ;
Message_Get(25,_lpszTmp,sizeof(_szTmp)) ;
_Lvc.pszText = _szTmp ;


ListView_InsertColumn(hListView_w1,5,&_Lvc) ;


_Lvc.cx = 40 ;
_Lvc.pszText = "NEA" ;


ListView_InsertColumn(hListView_w1,6,&_Lvc) ;


_Lvc.pszText = "PHA" ;


ListView_InsertColumn(hListView_w1,7,&_Lvc) ;


// e, a, q, i, om, w, ma, ad, n, per, per_y, moid, class


// e = Eccentricity
// a = Semi-major axis (au)
// q =
// i = Inclination of orbit plane (DEG)
// om = Longitude of Ascending Node (DEG)
// w = Argument of Perihelion (DEG)
// ma = Mean anomaly (DEG)
// ad = Aphelion distance (au)
// n = Mean motion (DEG/DAY)
// per = Orbital period (DAYS)
// per_y = Orbital period (YRS)
// moid = Distance minimale d'intersection d'une orbite
// class = Classe d'orbite


_Lvc.fmt = LVCFMT_RIGHT ;
_Lvc.cx = 90 ;
_Lvc.pszText = "e" ;


ListView_InsertColumn(hListView_w1,8,&_Lvc) ;


_Lvc.pszText = "a" ;
_Lvc.cx = 135 ;


ListView_InsertColumn(hListView_w1,9,&_Lvc) ;


_Lvc.pszText = "q" ;


ListView_InsertColumn(hListView_w1,10,&_Lvc) ;


_Lvc.pszText = "i" ;
_Lvc.cx = 90 ;


ListView_InsertColumn(hListView_w1,11,&_Lvc) ;


_Lvc.pszText = "om" ;


ListView_InsertColumn(hListView_w1,12,&_Lvc) ;


_Lvc.pszText = "w" ;


ListView_InsertColumn(hListView_w1,13,&_Lvc) ;


_Lvc.pszText = "ma" ;


ListView_InsertColumn(hListView_w1,14,&_Lvc) ;


_Lvc.pszText = "ad" ;
_Lvc.cx = 135 ;


ListView_InsertColumn(hListView_w1,15,&_Lvc) ;


_Lvc.pszText = "n" ;
_Lvc.cx = 90 ;


ListView_InsertColumn(hListView_w1,16,&_Lvc) ;


_Lvc.pszText = "per_d" ;


ListView_InsertColumn(hListView_w1,17,&_Lvc) ;


_Lvc.pszText = "per_y" ;


ListView_InsertColumn(hListView_w1,18,&_Lvc) ;


_Lvc.pszText = "MOID" ;


ListView_InsertColumn(hListView_w1,19,&_Lvc) ;


ListView_DeleteColumn(hListView_w1,0) ;


// On affiche aussi bien les astéroïdes que les comètes et les planètes
// Au départ on affiche les asteroïdes sans différienciation Observer, Vectors et Elements
// On vérifie simplement que les fichiers existent


memset(&_Work,0,sizeof(WORKDATAS)) ;


sqlite3_exec(hWorkDataBase,szEmptyWorkTable,0,0,NULL) ;
sqlite3_exec(hWorkDataBase,"BEGIN TRANSACTION",0,0,NULL) ;
Filtre_000(__hWnd,&_Work) ;
sqlite3_exec(hWorkDataBase,"END TRANSACTION",0,0,NULL) ;
sqlite3_exec(hWorkDataBase,"VACUUM",0,0,NULL) ;


return ;
}
Quote
Building Chloe.obj.
Building Chloe.res.
Building Filtres.obj.
Building Language.obj.
Building Log.obj.
Building Orbites.obj.
Building Utilities.obj.
Building Window-01.obj.
Building Window-02.obj.
Building Window-03.obj.
Building Window-04.obj.
Building Window-05.obj.
Building Chloe.exe.
POLINK: warning: Realigned section '.idata$5' in object 'sqlite3.lib(sqlite3.dll)' (from 4 to 8 byte(s)).
POLINK: warning: Realigned section '.idata$4' in object 'sqlite3.lib(sqlite3.dll)' (from 4 to 8 byte(s)).
POLINK: warning: Realigned section '.idata$2' in object 'libgfl.lib(libgfl340.dll)' (from 4 to 1 byte(s)).
Done.


Thanks again

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Bug
« Reply #7 on: July 23, 2020, 01:43:39 PM »
Good  :)
/Pelle

Grincheux

  • Guest
Re: Bug
« Reply #8 on: August 04, 2020, 08:01:33 PM »
Here is why I asked some help

Offline John Z

  • Member
  • *
  • Posts: 790
Re: Bug
« Reply #9 on: August 05, 2020, 11:19:40 AM »
Very cool!
A lot of computation I'm sure.


John Z

Grincheux

  • Guest
Re: Bug
« Reply #10 on: August 05, 2020, 05:46:06 PM »
No but big and numerous ephemeris to download. For this picture there are 1 500 000 points.
The most difficult is to choose the bitmap size. In the previous version I had bitmap of 8 000 x 8 000 pixels.
Now I directly create a 1 024 x 1 024 bitmap. It is long to draw, the sqlite tables must be sorted and a VACUMM must be made after every import... For one asteroid I download an ephemeris for the following dates
1-2000-2050
2-2000-2010
3-2010-2020
4-2020-2030
5-2030-2040
6-2040-2050
7-2000-2020
8-2000-2030
9-2000-2040


Each ephemeris has 90022 line of datas and is 23Mb in size...
Perhaps I could be faster if datas where not stored as reals but as integers.
I use SetPixel to draw the orbite.


Thank you Pelle & John for your comments.