Closed hoffie closed 3 years ago
I haven't double-checked, but git bisect
points towards c8bfa4fcb4a5aa06dcba4ac0c2e69ad8b8a60a7a as the culprit (as @softins already suspected :)).
(I'm not currently working on this further, feel free to follow up; if I have time, I'll comment here)
Interesting issue, I will try to see if I can find the solution for this. I can easy reproduce this on my system. I don't even have to change it twice. When I start the server (previous with 3.6.2 I had selected a folder for recording) and go to the directory setting, changing the folder crashes the application instantly. I recently got debug working in QT, so hope I can find what is causing this with the information already provided.
If 3.7.0 is affected why do you think it's related to 664fd9e? Wasn't this commit after release 3.7.0?
@henkdegroot Cool! I'm assigning this issue to you unless you state otherwise. Please keep us posted here. :)
If 3.7.0 is affected why do you think it's related to 664fd9e? Wasn't this commit after release 3.7.0?
I only wanted to state that 664fd9e is also affected. I didn't intend to say that it is the cause. I suspect c8bfa4f to be the cause. Reverting it will most likely fix the crash, but will also probably re-introduce the memory leaks (I still haven't verified that though).
c8bfa4f has indeed introduced this. When I comment out the
delete pJamRecorder;
at line 97, the crash no longer occurs.
Also believe my issue (with an already populated directory in the settings) and the issue you described (changing for the second time) is the same, provided you started with a "empty" directory.
Thinking it might be the recorder got never fully initialized (as no recording was performed yet). Will look into this further, but just wanted to share this.
@softins I am trying to find the best way to resolve this issue and would like to get your input, as it seems my knowledge is failing... You have been fixing some memory leaks in the recorder area and part of that code is to implement a "delete" on the pJamRecorder. This delete seems to crash the server application in some circumstances. I wonder if the delete is actually performed twice?
What I found in jamcontroller.cpp is:
emit EndRecorderThread();
pthJamRecorder->wait();
delete pthJamRecorder;
pthJamRecorder = nullptr;
--- some more code lines removed here ---
delete pJamRecorder;
pJamRecorder = nullptr;
Just listed the part of interest here.
Also found the following connect in the file:
QObject::connect ( pthJamRecorder, &QThread::finished,
pJamRecorder, &QObject::deleteLater );
My thought is that this connect to the pthJamRecorder thread finished is already triggering the delete of the pJamRecorder. For that reason I believe the "manual" coding of the delete pJamRecorder (and setting it to nullptr) is not needed. Obviously I do not want to introduce a memory leak....and have limited knowledge in that area.
When the "delete pJamRecorder" is removed from the code, the server app no longer crashes. When the "connect" is removed (and the delete is kept in place), the server app no longer crashes.
Hope you have some time to share your thoughts/opinion on this.
@henkdegroot my time is currently limited due to family circumstances, but I did spend a couple of hours looking at this yesterday, and found similar to what you have. I need to spend some more time to fully understand the interactions between the objects. I'll reply more later.
@softins thank you for the reply. Will wait for you later....I will try to find more myself as well. So far I did noticed that (while I have debug running) I see the pJamRecorder thread has values set up to the moment the pthJamRecorder gets deleted. When it gets deleted I see some values turn into "not accessible". Not always that same items are showing this, but most of the time the recordBaseDir is showing this. Sometimes I have even seen this on the pJamRecorder item itself (not accessible) as well. Hope this helps.
@henkdegroot Thanks for your analysis!
For that reason I believe the "manual" coding of the delete pJamRecorder (and setting it to nullptr) is not needed. Obviously I do not want to introduce a memory leak....and have limited knowledge in that area.
When the "delete pJamRecorder" is removed from the code, the server app no longer crashes. When the "connect" is removed (and the delete is kept in place), the server app no longer crashes.
I can confirm and I agree.
Side note: I had tried replacing the delete
with a pJamRecorder->deleteLater()
, which, according to the docs, is safe to be called multiple times. However, Jamulus still crashed.
I believe it is safe and correct to remove the delete pJamRecorder
call. Reasoning:
pJamRecorder
is guaranteed to be cleaned up when pthJamRecorder
finishes.pthJamRecorder
not being cleaned up properly. pthJamRecorder
does seem to be cleaned up properly.pthJamRecorder
not finishing in a reasonable time (not sure, but I think this is ok)@henkdegroot Can you open a PR to do just that? I think @softins and @pljones should have the final call here. Having the PR ready would speed things up a bit so that we can include it into the upcoming release.
OK, having checked the identified problem - and as this is effectively reverting to what I originally wrote ;) - I can say I'm happy.
@henkdegroot Can you open a PR to do just that? I think @softins and @pljones should have the final call here. Having the PR ready would speed things up a bit so that we can include it into the upcoming release.
Thanks for checking. Will do the PR shortly.
Describe the bug
Jamulus Server crashes when changing the recording directory in the UI for the second time. This even happens when there is no active recording.
To Reproduce
Expected behavior
As @softins suggested, the recording directory should probably be unchangable when recording is active.
Screenshots
systemd logs this stack trace, although I'm not sure if it is relevant or helpful at all.
Operating system
Arch Linux, 5.11.10-arch1-1, Qt 5.15.2
Version of Jamulus
Additional context
3.6.2 does not have this problem.