Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Editing a Polar file in Dim Tab, insert TWS=11 causes Opencpn Crash-READ ONLY #170

Closed
rgleason opened this issue Mar 17, 2018 · 47 comments

Comments

@rgleason
Copy link
Contributor

rgleason commented Mar 17, 2018

BlockIsland40-BAD.zip
blockisland40-bad pol-edit-dim-tab

Its as simple as that. Was trying to edit the BlockIsland40.pol to show BAD polars.

@rgleason rgleason changed the title Editing a Polar file in Dim Tab, insert TWS=11 causes Opencpn Crash Bug: Editing a Polar file in Dim Tab, insert TWS=11 causes Opencpn Crash Mar 18, 2018
@rgleason
Copy link
Contributor Author

rgleason commented Mar 18, 2018

screenshot 206
A crash also occurs using polar Example 0-10.pol and going to Edit Polar, Dim Tab.
Try to insert TWS=11 it will crash.

@rgleason
Copy link
Contributor Author

The problem is it crashes when you try to "SAVE"

@rgleason
Copy link
Contributor Author

I have tried wxRte with MSVC++ debug. For some reason I was not able to get a failure and call back report. It worked! These are screenshots. I don't have an error code as a consequence.
screenshot 209
screenshot 211
screenshot 212

screenshot 213

screenshot 214

@rgleason
Copy link
Contributor Author

I thought I had figured it out.
I found my programdata/opentpn/plugins/weather_routing/polars folder was set to write protected.
I undid that and also the other folders. Then started Opecpn and WxRte.
At first I could edit a polar removing and adding to the polar in the Dim Tab. I saved. it worked.
The next time I opened the file, I could not save and Opencpn Failed.

So what the XXXX is the program doing? Setting the user files to READ ONLY??????
NUTS.

@rgleason rgleason changed the title Bug: Editing a Polar file in Dim Tab, insert TWS=11 causes Opencpn Crash Bug: Editing a Polar file in Dim Tab, insert TWS=11 causes Opencpn Crash-READ ONLY Mar 18, 2018
@rgleason
Copy link
Contributor Author

rgleason commented Mar 18, 2018

Editing a Polar in the Dim Tab is totally unusable because the folders are set to READ ONLY, so changing the file at all causes Opencpn to Fail. I believe the program is changing the setting to Read Only, because I have unchecked and applied the read only, and it just comes back when the program is loaded at some point!

@seandepagnier
Copy link
Owner

seandepagnier commented Mar 18, 2018 via email

@rgleason
Copy link
Contributor Author

Why does the program keep changing these USER folders to Read Only?
Does this happen in Linux?
There is another user reporting this problem.

@rgleason
Copy link
Contributor Author

Is this some Windows setting perhaps?

@rgleason
Copy link
Contributor Author

rgleason commented Mar 18, 2018

I've checked it. I don't believe it is the read only settings, when I go down to the next folder, everything is read/write/execute. So it has nothing to do with read/write IMHO

Also, why does the Plugin save changes in the Polar Tab when it is on Grid Tab but not when they are changes in the Dim Tab?

As I said originally, it is a bad command or statement in the Dim Tab section of the program.

The fact that it is saving properly from the Grid Tab indicates it has nothing to do with read-write issues., and indicates it is a program issue!

@rgleason
Copy link
Contributor Author

rgleason commented Mar 18, 2018

EditPolarDialog.ccpp

Line 63 void EditPolarDialog::OnPolarGridChanged( wxGridEvent& event )
Line 68 m_BoatDialog->Refresh();

Line 188 void EditPolarDialog::RebuildGrid()
...to remove and add rows and columns
Line 213 m_BoatDialog->Refresh();

Are the two tabs Grid Tab and Dim Tab using the same save function?

I am thinking back to all the trouble we had with EOL and Cel_Nav did not work for about 3 months I think. Finally Stelian fixed it. seandepagnier/celestial_navigation_pi#19
"Fix crash on windows due to bad dealing with EOL."

This appears to be another one of those problems.

@stelian42
Copy link
Contributor

I can reproduce this on Linux too, although it can take several tries to make it happen.

Just use BlockIsland40-BAD.pol from the top of this bug report, put the polar in ~/.opencpn/plugins/weather_routing/polars, edit some boat, add the polar to the boat, edit the polar, go to dimension tab, put 11 in the TWS field, click add. At this point it will hang, and the gdb shows:

Thread 1 "opencpn" received signal SIGINT, Interrupt.
positive_degrees (degrees=12484250495091552)
at /home/stelian/TMP/ocpn_pi/weather_routing_pi_stelian.git/src/Utilities.cpp:56
56 degrees -= 360;
(gdb) bt
#0 0x00007fffcdb0e450 in positive_degrees(double) (degrees=12484250495091552)
at /home/stelian/TMP/ocpn_pi/weather_routing_pi_stelian.git/src/Utilities.cpp:56
#1 0x00007fffcdaea280 in Polar::Speed(double, double, bool, bool) (this=0x55555a79ac60, W=12485134922022912, VW=11, bound=false, optimize_tacking=false)
at /home/stelian/TMP/ocpn_pi/weather_routing_pi_stelian.git/src/Polar.cpp:480
#2 0x00007fffcdace2cb in BoatDialog::OnPaintPlot(wxPaintEvent&) (this=
0x55555a3167c0, event=...)
at /home/stelian/TMP/ocpn_pi/weather_routing_pi_stelian.git/src/BoatDialog.cpp:446
#3 0x00007ffff523a7ee in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#4 0x00007ffff523abfa in wxEvtHandler::SearchDynamicEventTable(wxEvent&) ()
at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
...

(gdb) up
#1 0x00007fffcdaea280 in Polar::Speed (this=0x55555a79ac60, W=12485134922022912, VW=11,
bound=false, optimize_tacking=false)
at /home/stelian/TMP/ocpn_pi/weather_routing_pi_stelian.git/src/Polar.cpp:480
480 W = positive_degrees(W);
(gdb) up
#2 0x00007fffcdace2cb in BoatDialog::OnPaintPlot (this=0x55555a3167c0, event=...)
at /home/stelian/TMP/ocpn_pi/weather_routing_pi_stelian.git/src/BoatDialog.cpp:446
446 double VB = polar.Speed(W, VW);
(gdb) p W
$1 = 12485134922022912

Something is wrong here, I'd say the main EditBoat window is receiving paint events while the wind speed data is not fully initialized...

@stelian42
Copy link
Contributor

I hopefully fixed this is #179 (but haven't tried yet on Windows).

@stelian42
Copy link
Contributor

Now that Sean merged this, can you please Rick see if there are still issues on Windows ?

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

Stelian, I tried #179 first in release and it did not work, then in debug mode to get a callback to isolate the problem and and the darn plugin ran great. I could add and delete rows and columns and save the polar with no problem! -Debug was not a big help!

See my note from last night please at the bottom.
46ecc9d

#170
I am going to try it again this morning (Release mode) to try to report exactly what happens.

  1. I was able to add a TWS 0 column and was able to save then save the boat. Then edited polar again and saw the first col of zeros in the grid.
  2. Then I tried adding a column TWS 16 in Dim Tab. It seemed to be accepted when I hit Save Boat. The blue spinner started and has been going for about 4 minutes.
    I wonder what is causing this?

More in a minute.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

It failed OPencpn. Next time, I was able to remove the row of zeros at TWA=0, Also the column of zeros at TWS=0, Save, then Save Boat, Close the menu. Then reopen the Boat Edit Menu. When I went to Edit Polar, the polar was what I expected with TWA=0 row gone, but the TWS-0 column remained..

Ok, now I have through the Dim Tab removed the TWS=16 column and Saved then Saved boat, then reopened and gone to Edit Polar and TWS=16 column is gone.

It is just that TWS=0 does not want to be removed for some reason. I am going to attach 3 photos. I've noticed that I can no longer have polar edit up and see the polar diagram, is that necessary? It was a great help. if it is possible to have diagram refresh each time a change is made, it would be easier... but maybe that was one of the problems....

screenshot 234
screenshot 235
screenshot 236
Anyway the Grid Tab shows TWS=0 colmn of 0'S, each time I remove it. Is the program puttng these back in now, insisting that there be a first TWS=0 column of zeros?
It looks like it becase all the other polars have this col of zeros.

So I am assuming that Removal of Columns and Rows works properly now. It would be nice if Sean could confirm that all polars are given TWS=0 first column of zeros even if they do not have it.

@rgleason
Copy link
Contributor Author

I can remove multiple columns, one at a time, before saving (except TWS=0 col).
I can remove multiple rows, one at a time, before saving.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

When I go into Edit and Dim Tab and enter into TWS the value 12 and hit Add, the twelve appears at the bottom. Then I hit SAVE and the menu closes as is normal, then the blue spinner appears. There will be a crash of Openpn now.

I try to hit the X on the menu, get message O not responding, then MS message about O failure.

Now I restart O and bring up the same Edit Polar --- There is a TWS=12 Column!! so it manged to save to the file. What was the cause of O stopping then?

screenshot 239

@rgleason
Copy link
Contributor Author

Then I was able to add TWA=105 and TWA=125 and Hit save. and the polar diagram looked unusable but they saved.
Then I could delete TWA=105 and TWS=125. and the polar went back to reasonable.
Then I tried removing TWA=0 and TWS=0 only TWA=0 Row was removed.
No hang ups there.
screenshot 242
screenshot 243
screenshot 244
screenshot 245

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

Summary: The problem stems from trying to add a new TWS.
The new TWS column seems to get written to the file, but OpenCpn seems to hang up directly afterwards.
This problem is somewhat intermittant. Sometimes it happens, sometimes not. I just added three columns and edited the cells and tried to save and got a blue spinner. The time before that it saved successfully while just adding a column.

@stelian42
Copy link
Contributor

Rick,

On what version of OpenCPN are you doing this test ? Also, how do you compile the plugin ? (which version of visual studio, wxwidgets etc)

Can you reproduce with the official OpenCPN 4.8.2 and the plugin compiled by appveyor ?

I cannot reproduce the problem here...

@rgleason
Copy link
Contributor Author

I am still using MSVC 2013 and wxWidgets 3.0.2 because I want to be able to compile for v4.8.2 specifically. I have found that some of Jon Gough's versions of ocpn_draw, compiled usng MSVC2017 did not run with v4.8.2 so I am sticking with VC2013 + wxWidgets 3.0.2 on this machine for awhile. Why?

I compile as standalone plugin, and I am using opencpn.lib with 135kb which is the one from v4.8.0
which is

api114 (1.14)= OpenCPN 4.8.0 ←Changed API 1.14 to work in MS Windows for BR24beta Externalize AIS drawing #869 8/10/2017 .
What are you using?

@rgleason
Copy link
Contributor Author

In weatherrouting.h

#include "version.h"

#define     MY_API_VERSION_MAJOR    1
#define     MY_API_VERSION_MINOR    13

So I guess I could step back to

pi113 (1.13) = OpenCPN 4.2 ←SVG Icons added (gtk,expat,vc,etc)

@stelian42
Copy link
Contributor

We're using the same versions of MSVC and wxwidgets. My opencpn.lib is 138 KB, I obtained it by compiling opencpn locally on this machine, not sure what version though.

Here is attached my weather_routing installer can you please test it ?

wr.zip

@stelian42
Copy link
Contributor

Here is the full combo: opencpn (4.8.2) + WR: http://popies.net/tmp/oc.zip

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

stelian, I think /know you're using the opencpn.lib version from v4.8.2 it is 138kb

pi115 (1.15)= OpenCPN 4.8.2 <- Extend with functions providing min/max available basemap quality #974
                           <--Fix Grib plugin to use same screen size as main application #893
						   <--Implement route api for plugins #996
						   <--implement api call for plugin to handle autopilot routing #996
						   <--correct route and track messages so they can actually be used by plugins #995

Thanks I'll try yours now.

@stelian42
Copy link
Contributor

In the "full combo" zip I posted above I've updated my local OpenCPN git to v4.8.2, and compiled it, and used its opencpn.lib to build WR. No issues so far here.

@rgleason
Copy link
Contributor Author

Everything was going fine, removed a couple of columns. Then tried to add TWS=1 column.
Entered 1 Hit Add. It accepted. Then went to "Save Boat" and the darn spinner showed up.
I tried to capture some shots as it was happening.

This is the blue spinner shot after hitting "Save Boat"
screenshot 247

Then crash
screenshot 248

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

Did this with your WR .zip.
Maybe I should be doing this with a totally clean installation with grib_pi and climatology?

I can use the a portable build in my Msvc setup. Won't be hard. What do you think?

I think I'll download the full deal and install in a different setup

@stelian42
Copy link
Contributor

It might be worth giving a try to a totally clean installation. You don't need grib_pi or climatology, try just the two installers in my oc.zip combo.

@rgleason
Copy link
Contributor Author

screenshot 250
I downloaded the full OCpn and tried to install, but it wouldn't start. I notice it has a smaller file than mine from the website, so I installed that and its running again. I brought up your version (I installed it a second time to be sure) and low and behold the file I was using had been saved so the the TWS=1 column was now there. (This was just above after hitting "Save Boat", when I got the blue spinner!

So the file is being saved, but when I hit "Save Boat" something else is causing the program to fail.

Here is the file with the TWS=1 column.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

Ok so this time I got a little aggresive and added one at a time TWS 1.5, Add, 1.7 Add, , 1.8,Add, 1.9 Add , I see the values all in there in the correct order, and Saved.
Then I hit "Edit" because I wanted to see them entered.
Instead I got the blue spinner!

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

Restart OPencpn and bring up WxRte
Well will you look at that. They all made it in there except why does it fail?
It seems to fail these time:

  1. Enter a new TWS column. 1.5 in the box and hit ADD
  2. Do 1, then Hit "Save" it saves ok. Then hit " Save Boat" ---> Blue Spinner
  3. Do 1, then Hit "Edit" ---> immediate blue spinner.
  4. In both cases the columns seen to get entered and you see them the next time you start Opencpn up.

screenshot 252

@rgleason
Copy link
Contributor Author

I tried renaming my opencpn.ini and just adding wxrte grib and climatology.
It was going great, and then after some changes, adding cols and rows, I was going to go back and see the changes and hit "Edit" got the blue spinner again.

@rgleason
Copy link
Contributor Author

Ok, I have a portable version I should be using for this, set up with Batchutils Tdan.

I go to C:\Users\Frederick\Documents\GitHub\OpenCPN\build\Release
and type Opencpn -p and its right there. Now I just have to intall your version of WR and test away.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

Well, it is still failing, even with a clean release install using portable, installing your WR.
I added 1 col and five TWS 1, Add, 2, Add ,3, Add ,4, Add, 5, Add It looked like it saved ok.
This time i went to "Save Boat" immediate blue spinner and eventual failure.

This is in a crystal clean release version envirionment with few plugins and a simple opencpn.ini

Then I went back and loaded O & WR and found that the polar file was saved just as I thought, even though the program failed when I hit "Save Boat"
screenshot 257

Aren't you getting these errors?

@rgleason
Copy link
Contributor Author

rgleason commented Mar 20, 2018

Restart Portable Opencpn in C:\Users..\GitHub\OpenCPN\build\Release with "opencpn -p" and bring up WxRte The changes all made it into the polar file, but why does it fail?
It seems to fail these time:

1. Enter a new TWS column. 1.5, Add, 1.6, Add, etc.
2. Do 1, then Hit "Save" it saves ok. Then hit " Save Boat" ---> Blue Spinner
3. Do 1, then Hit "Edit" ---> immediate blue spinner.
In both cases the columns seen to get entered and you see them the next time you start Opencpn up.

After continuing the tests, I found this is real.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 21, 2018

Stelian, What EOL do the polars have? What are they required to have for EOL?
What happens if I open a polar file with Notepad++ and I see ,<CR><LF> when it is saved?
Will the WxRte program interpret these files properly and save them back to the format needed?
Would this EOL thing cause troubles saving?

Also I am going to have to trough and check all the polar to make sure they work and are in the correct form. I don't want notepad++ which I may have to use, to cause troubles!

@stelian42
Copy link
Contributor

Rick,

"I downloaded the full OCpn and tried to install, but it wouldn't start. ". Is this with the opencpn installer from my oc.zip ? Something is really wrong on your system, the installer works ok here. Please make sure you downloaded/extracted the zip correctly.

I cannot reproduce your issues at all, so:

  1. the problem may be because we're not using the same code (this is why I insist, try with my versions, or otherwise give my your installers so I can test with them)
  2. the issue may be caused by something related to the speed of execution (this could explain why you're seeing it in release mode only, and not in debug mode, and why I cannot reproduce it in my virtual machine which is slower than a normal machine)
  3. or we're not doing exactly the same test scenario (that's why I asked for a full scenario)

I don't believe this to be related to EOL issues, because if it was the case, it should happen every time, on all Windows machines, not only on yours. But I'll still look at the code to see how EOL are dealt with.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 21, 2018

Yes, the opencpn installer from oc.zip. I am going to install it on my laptop Win10 (a different machine) to eliminate that issue. I know how infuriating this is. Thankyou for sticking with me.

However, would you try something for me? Try inserting two or three TWS columns successively.
Say 1.5 "Add", "1.6", Add "18", Add then "Save". Then "Save Boat"

PS: I've removed all plugins except the 4 standard, wxrte, climatology and wxfax from this SurfacePro3 and started it with a fresh ini. I removed a large number of plugins. I still fails as above.

Now I am going to remove my 4.8.2 configuration on my laptop and install yours. For some reason, oc.zip exe installed on the SurfacePro3 earlier, but would not start, even when I went to the file and executed as admin. If this happens on the laptop, I will just copy the executable from the other machine and try it, leaving everything else the same.

@stelian42
Copy link
Contributor

"However, would you try something for me? Try inserting two or three TWS columns successively.
Say 1.5 "Add", "1.6", Add "18", Add then "Save". Then "Save Boat""

I did try this multiple times. No problem here.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 21, 2018

Good. Turns out I don't have 4.8.2 on the laptop, so its a clean parallel install. It installed and it works.
I installed your wxrte and then made copies of Boat-Climatology-copy.xml and the Example-15-30-copy.pol and used those.

In TWS Column I added 1.5 "add" 45 "add"
"save" - worked
"save boat" - blue spinner
--what a pain

@rgleason
Copy link
Contributor Author

Windows does this. Pavel had a similar situation where he thought it was my machine. Then he came up with some alternate code that worked. I am trying to remember which plugin it was. Possibly Squiddio.
He said when he got it working & I asked why, he said some microsoft machines had trouble with that particular set of commands. I will try to find it.

@rgleason
Copy link
Contributor Author

rgleason commented Mar 21, 2018

I looked under squiddio on github, can't find it. I think I am losing it. I've tested to many plugins!
Perhaps I should try the MSVC++ debug route again? Maybe it will work with the improvements you've already made? I think I'll do that.

@stelian42
Copy link
Contributor

Sorry Rick but I tried what you say in #170 (comment) and it works here...

@rgleason
Copy link
Contributor Author

I have 2 machines that do this so it is not uncommon. --Well, we know that the file is updated accordingly, and you just have to restart Opencpn etc. So what is this 1/2 a bug? I am going to try to get some callback codes with MSVC++ and if that doesn't work. I am going to pretend it works.

Thanks for bringing it this far! It is much much better. Sorry we couldn't identify the clitch.

@stelian42
Copy link
Contributor

No, don't close, keep this open.

You are encountering a bug, and just because I'm not able to reproduce it on my very limited setup doesn't mean the bug doesn't exist !

@rgleason rgleason reopened this Mar 21, 2018
@rgleason
Copy link
Contributor Author

Merge pull request #179 from stelian42/fix-edit-polar-paint Fix crash when editing polars caused by spurious paint events.
Merge pull request #178 from stelian42/fix-edit-polar-crash-if-sel-empty Fix crash in edit polar dialog when clicking on "Remove" if there
Fix crash on save polar #182 opened an hour ago by stelian42

Fix example configurations and polars #181 opened 4 hours ago by stelian42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants