-
Notifications
You must be signed in to change notification settings - Fork 381
gmtinfo -i from externals is screwing on Windows #5311
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
Comments
In matlab on mac it works: a = gmt ('info', '-C -i0-2,2', rand(5,3)) a = struct with fields:
If this is a win gmt api issue the it should also fail for you in matlab on Windows, right? |
Yes, it fails on Matlab too. Seems to return uninitialized memory for the last 4 elements. |
OK, maybe you can step through then and look for any clues since I cannot make it fail. |
I should mention that we very recently made edits to gmt_api.c related to reading both rec-by-rec (gmt info I think) and tables from virtual memory given as vectors, and related to -i. Are you passing these as a matrix or set of vectors? |
Can you please verify that you are building with latest GMT (6.2.0 or master)? I cannot see anything obvious in the code section and it works in mex for me. These assignments take places in gmtinfo.c directly into GMT->current.io.curr_rec which is BUFSIZE long, so if things are wrong it is hard to guess where that happens without you stepping through for a clue. |
I better be using 6.2.0 otherwise the Win installer ... 😄 I'll try to find it. |
I looked in the GMT_Get_Record that takes you into the read record from matrix section but could not see anything wrong...hence we need a hint. |
Must be the f
Remember that we once had an issue with it and I even opened an issue in Microsoft that they refused saying the behavior was undefined by C standards so the shit they did was legal. |
Sorry, was on a zoom. Looking now. I do vaguely remember qsort etc. Are you able to see what the order is before qsort? But would not this problem also affect command line usage since this is the common parsing of -i? I cannot see how a bug there would not show up equally in mex, Julia AND command line? |
Is it this issue you mean: https://github.com/MicrosoftDocs/cpp-docs/issues/2303 |
Don't know if a repeated one but it's not the same because the other one was opened by me. And pre GH times. The command line does the same thing but they are not used later. Instead the |
Wonder if you could build GMT with our compat/qsort instead. I think it means getting HAVE_QSORT_R_GLIBC set to false so the code is included. As a check, you could edit compat/qsort.? and change #ifndef HAVE_QSORT_R_GLIBC to #ifdef WIN32 and that should do it! |
Nope. That file has The problem is definitely the |
From macos man page on qsort_r:
Maybe you could replace that qsort with mergesort (same args) and see what happens? Speed here is irrelevant since we are sorting tiny arrays, so stability is better. |
Yep, mergesort works. THIS QSORT(S) THING IS ABSOLUTELY INSANE. |
Probably the source of the PyGMT test failure on Win
but it works well on Linux
It works well on Win if instead of an array we pass in a file name or if we pass a simpler (and redundant) -i0-2 option
The text was updated successfully, but these errors were encountered: