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

msvc #4384

Closed
wants to merge 31 commits into from
Closed

msvc #4384

wants to merge 31 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 30, 2018

Here's the latest. It's flawed (read TODO notes). It works with 2015. Depending on the merge in zynaddsubfx repo, you might have to change some links.

I'll make a new branch, so you can pick and choose what modification you accept (if any). I haven't tested it on linux.

Azrael added 30 commits May 11, 2018 13:17
+locale: using path instead of individual files to reduce command line
size
+remotevstplugin: changed order return type & calling convention
(compiler error)
+lmmsobj: removed single quotes for command line defines
+added toolchain file
+added toolset
+carla: exports header
+package_linux: corrected RemoteVstPlugin name
+vstbase: toolchain file conditional on MSVC
todo: volume too loud? clipping
*switched temp switched zynaddsubfx submodule
*updated code to work with msvc
-dependency jackaudio & jackmidi (caused crash on exit)
+jack midi out
@fundamental
Copy link
Contributor

Parroting one comment from the PR on lmms's zyn fork. std::vector should NOT appear in realtime code. LMMS has numerous problems in terms of realtime safety already and it should not make the situation worse for itself.

@lieff
Copy link

lieff commented May 31, 2018

-    		QAction *presetActions[list1.size()];
+    		std::vector<QAction*> presetActions(list1.size());

Right, std::vector internally calls malloc() while original code uses stack pointer advance.
alloca() can be used for dynamic stack allocation, it works on all modern compilers.

@fundamental
Copy link
Contributor

Or just use MSVC 2017, which to the best of my knowledge supports VLAs.

@lukas-w
Copy link
Member

lukas-w commented May 31, 2018

If I recall correctly, MSVC 2017 doesn't support VLAs either, which is also what the documentation says.

We can use QVarLengthArray where Qt is available, just like in #4000.

@fundamental
Copy link
Contributor

@lukas-w the linked page is dated 11/04/2016.

@lukas-w
Copy link
Member

lukas-w commented May 31, 2018

@fundamental Good catch. :)

@fundamental
Copy link
Contributor

Additionally QVarLengthArray does fall back onto using malloc()/free() in some cases.
See https://github.com/qt/qtbase/blob/e843e3bb00d26c841bd7132c00779c085368eab3/src/corelib/tools/qvarlengtharray.h and search around for free/malloc.

@lukas-w
Copy link
Member

lukas-w commented Jun 1, 2018

@fundamental I'd argue that falling back to malloc is better than failing silently. On the other hand, I didn't realise QVarLengthArray doesn't even use alloca, but just a fixed-size preallocated array. So I guess we're left with checking if MSVC2017 supports VLAs or using alloca if it doesn't.

@ghost
Copy link
Author

ghost commented Jun 1, 2018

It doesn't.
IIRC, VLA is only in the C99 standard and never made it into the c++ standard. Using VLA in c++ code is a gnu extension to the c++ standard.

edit: not making a judgement call whether this is good/bad or anything.

@ghost
Copy link
Author

ghost commented Jun 1, 2018

We're getting a bit off track by focusing on the details.

I did this in the first place to have debug symbols.
It's maybe a controversial idea, but if nobody uses this setup upstream (or even in lmms) then maybe it's better not to try to merge. It works upstream. The changes are still public so if someone wants to tackle it in the future they have a reference of the mistakes and successes of the initial attempt.

(feel free to skip the rest, it's only an example why debug symbols are important to me)

The latest commit to lmms in this PR is an example of that (jack midi thing), it took me literally less than 5 minutes to find the cause.

Lmms crashed on exit, I attached visual studio and I could navigate the call stack with source code displayed. I've compiled all the libs lmms is using with debug information.

It crashed inside jack, I have jack compiled with debug info so I know where it crashed in jack. Going up the stack frame, I saw it was called from a destructor of MidiJack (typing from memory, so the names might be wrong). Further up the stack: mixer destructor was called which destroyed audiojack first and midijack shared the connection with audiojack.

@lieff
Copy link

lieff commented Jun 1, 2018

Build with -g -rdynamic should produce good call stacks on linux too. But I think it's good to support msvc using alloca.

This pull request was closed.
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

Successfully merging this pull request may close these issues.

3 participants