LSCP memory problem, can't mlockall() warnings

You're new to the LinuxSampler world? You don't know where to start and nothing works? Here's the place to ask for help.
Post Reply
camobrite
Newbie
Posts: 20
Joined: Sat Mar 14, 2009 12:28 am

LSCP memory problem, can't mlockall() warnings

Post by camobrite » Sat Mar 21, 2009 5:51 am

Hi everyone, I've been having a weird problem with linuxsampler allocating memory for new samples. I compiled from the latest source on the CVS using dpkg-buildfile and the default config settings, running on a pentium 3 dell with debian testing.

When I start qsampler, I get the following message:

Code: Select all

00:44:32.617 Client connecting...
00:44:32.646 Server is starting...
00:44:32.659 linuxsampler
00:44:32.708 Server was started with PID=28260.
lscp_client_create: cmd: connect: Connection refused
LinuxSampler 0.5.1.11cvs
Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck
Copyright (C) 2005-2009 Christian Schoenebeck
Detected features: MMX SSE
Automatic Stacktrace: Off
Creating Sampler...OK
Registered sampler engines: 'GIG'
Registered MIDI input drivers: ALSA,JACK
Registered audio output drivers: ALSA,JACK
Loading instrument editor plugins...OK
Registered instrument editors: 'gigedit'
Starting LSCP network server (0.0.0.0:8888)...Thread: WARNING, can't mlockall() memory!
OK
00:44:35.994 Client connecting...
00:44:36.020 Client receive timeout is set to 1000 msec.
00:44:46.053 Client connected.
00:44:46.154 Sent fine tuning settings.
00:44:46.208 New session: "Untitled1".
LinuxSampler initialization completed. :-)

LSCPServer: Client connection established on socket:4.
LSCPServer: Client connection established on socket:5.
So there's a problem starting the LSCP network server.

Then, when I try to load a gig I get this output, including the warning, "Thread: WARNING, can't mlockall() memory!"

Code: Select all

00:46:28.559 New Channel setup...
00:46:39.361 Channel 0 added.
00:46:39.401 Channel 0 Audio driver: JACK.
00:46:39.435 Channel 0 MIDI driver: ALSA.
00:46:39.454 Channel 0 MIDI port: 0.
00:46:39.468 Channel 0 MIDI channel: 0.
00:46:39.509 Channel 0 Engine: GIG.
00:46:39.539 Channel 0 Instrument: "/home/bsmith/copy_of_Unsaved Gig File.gig" (0).
00:46:39.557 Channel 0 MIDI map: 0.
Thread: WARNING, can't assign realtime scheduling to thread!
Thread: WARNING, can't mlockall() memory!
Starting disk thread...Thread: WARNING, can't mlockall() memory!
OK
Thread: WARNING, can't mlockall() memory!
Scheduling '/home/bsmith/copy_of_Unsaved Gig File.gig' (Index=0) to be loaded in background (if not loaded yet).
Thread: WARNING, can't mlockall() memory!
Loading gig file '/home/bsmith/copy_of_Unsaved Gig File.gig'...OK
Loading gig instrument ('/home/bsmith/copy_of_Unsaved Gig File.gig',0)...OK
Caching initial samples...OK
00:46:48.045 Channel 0 edit instrument.
Found matching editor 'gigedit' for instrument ('/home/bsmith/copy_of_Unsaved Gig File.gig', 0) having data structure ('libgig','3.2.1')
InstrumentEditor::Launch(instr=826e030,type=libgig,version=3.2.1)
InstrumentEditor::Main()
Entered Gigedit Main() loop :)
Initializing 3rd party services needed by gigedit.
Loading a .gig file seems to work, and I can open up the instrument in gigedit. The samples included in the file get loaded and output fine, but when I try to add samples to the instrument, I get the message:

Adding sample /home/bsmith/documents/samples/Breaks/clnkrbrk.wav
Drop received sample "clnkrbrk"
Unable to cache sample - maybe memory full!

and no sound in regions that access the new sample.

When I try to delete a channel, another dialog comes up that says:

New Channel

Could not remove channel.

Sorry.

Then, it crashes with the output:
[2]- Segmentation fault qsampler

So it seems as though linuxsampler is having trouble allocating memory for new samples.

Maybe it has something to do with sqlite3. When I compiled linuxsampler, I got this message:

checking for SQLITE3... no
*** Required sqlite version not found!
*** You need to have sqlite version 3.3 or higher
*** for instruments database support to be enabled.
*** Support for instruments DB will be disabled!

However, I have sqlite 3.5.9 installed. Am I missing something? Any help would be appreciated.

-B

ggoodesa
Advanced User
Posts: 116
Joined: Thu Aug 14, 2008 6:48 pm

Re: LSCP memory problem, can't mlockall() warnings

Post by ggoodesa » Sat Mar 21, 2009 7:25 am

Hi B,
SQlite is used for instrument database support and is not a core component for running Linuxsampler or Gigedid (in the Windows version doesn't have sqlite built in yet), so SQlite is not the problem. I think you will need the development library of sqlite in order to compile linuxsampler with it (not just have the app installed). I'm not a developer, just a fellow user - so I have no idea about the other errors. Gigedit works fine on my system.
GrahamG

Andreas
Developer
Posts: 214
Joined: Sun Feb 03, 2008 8:33 am

Re: LSCP memory problem, can't mlockall() warnings

Post by Andreas » Sat Mar 21, 2009 11:20 am

camobrite wrote:Hi everyone, I've been having a weird problem with linuxsampler allocating memory for new samples.
It looks like there are several different problems.

Code: Select all

lscp_client_create: cmd: connect: Connection refused
This is normal, I think. QSampler can't connect to LS as LS isn't started, which just leads to QS starting LS itself.

Code: Select all

Starting LSCP network server (0.0.0.0:8888)...Thread: WARNING, can't mlockall() memory!
OK
The LSCP server starts OK. The warning about mlockall is just a warning, which tells you that the LS process is not allowed to lock the memory to RAM. This means that the operating system will be allowed to swap out the loaded instruments to disk, which will lead to playback drop-outs.

To make mlockall work, it is often enough to make sure that the current unix user is a member of the "audio" group. Look after "memlock" in /etc/security/limits.conf.

Code: Select all

Thread: WARNING, can't assign realtime scheduling to thread!
This is also an ulimit problem, the unix user need to have rtprio set to 99. Again, being a member of the audio group should be enough.

Code: Select all

Unable to cache sample - maybe memory full!
This sounds familiar, but unfortunately I don't remember the cause of this one.
When I try to delete a channel, another dialog comes up that says:

New Channel

Could not remove channel.

Sorry.

Then, it crashes with the output:
[2]- Segmentation fault qsampler
I don't think I heard of this one. It seems like a bug in qsampler. It is probably unrelated to the other problems.
Maybe it has something to do with sqlite3. When I compiled linuxsampler, I got this message:

checking for SQLITE3... no
*** Required sqlite version not found!
*** You need to have sqlite version 3.3 or higher
*** for instruments database support to be enabled.
*** Support for instruments DB will be disabled!
As GrahamG said, this is probably solved by installing a sqllite dev package. And it's not related to any of the other problems, it just disables the support for the instrument DB.

camobrite
Newbie
Posts: 20
Joined: Sat Mar 14, 2009 12:28 am

Re: LSCP memory problem, can't mlockall() warnings

Post by camobrite » Sat Mar 21, 2009 8:27 pm

Thanks for your response! The mlockall() warnings were in fact related to ulimits. I made my max memory lock unlimited and that got rid of the warnings. I still can't figure out how to give myself realtime priority (I'm in the audio group, and I added the line "@audio hard rtprio 99" to /etc/security/limits.conf" and logged back in, but ulimit -a still says that I have an rtprio of 0, and so does root. hmm.), but now I know how to attack the problem.

However, even running qsampler as root, I'm still getting the "can't cache sample - maybe memory's full!" warning when I try to add new samples. I looked at my memory usage, and even though I've only got a modest 512 megs of ram on my system, It was still complaining when I tried to load a 1.2 meg sample when I had 200 megs of free memory. Sometimes I get a dialog when I load an instrument that says "Channel 0 Some channel settings could not be set. Sorry." I don't know what this means.

I have been having problems with gigedit as well. When I try to save any file with a name other that "copy_of_Unsaved Gig File.gig", gigedit freezes right after saving, and I have to force quit it. Loading these half-saved files in qsampler leads to a dialog coming up that says "some channel settings could not be set. sorry" and "err-1" being displayed in the instument's channel strip. So the only gig files I can save in gigedit have to be called "copy_of_Unsaved Gig File.gig." Loading 3rd party gig files works in qsampler, but I still can't add samples to them.

Thanks again for your help, if noone knows what's wrong I'll open a bug report.

-B

camobrite
Newbie
Posts: 20
Joined: Sat Mar 14, 2009 12:28 am

Re: LSCP memory problem, can't mlockall() warnings

Post by camobrite » Sat Mar 21, 2009 9:03 pm

update: I got realtime scheduling to work and eliminated the realtime schedule warning, but I still get the "unable to cache sample" warning, the "some channel settings could not be set" dialog when I load the instrument, and the "could not remove channel" dialog and crash when I remove instruments.


Here's the output when I load a new channel:

Code: Select all

15:45:52.454 New Channel setup...
15:45:59.949 Channel 0 added.
15:46:00.979 Channel 0 lscp_set_channel_audio_type: Timeout during receive operation (errno=-4)
15:46:01.083 Channel 0 lscp_get_midi_device_info: DRIVER (errno=0)
jackd 0.109.2
Copyright 2001-2005 Paul Davis and others.
jackd comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details

JACK compiled with System V SHM support.
loading driver ..
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
control device hw:0
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 16bit little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 2 periods for playback


**** alsa_pcm: xrun of at least 1237654553231.360 msecs

15:46:01.232 Channel 0 MIDI driver: ALSA.
15:46:01.341 Channel 0 MIDI port: 0.
15:46:01.365 Channel 0 MIDI channel: 0.
15:46:01.990 Channel 0 Engine: GIG.
15:46:02.024 Channel 0 Instrument: "/home/bsmith/copy_of_Unsaved Gig File.gig" (0).
15:46:02.046 Channel 0 MIDI map: 0.
15:46:02.067 Channel 0 Some channel settings could not be set. Sorry.
Starting disk thread...OK
Scheduling '/home/bsmith/copy_of_Unsaved Gig File.gig' (Index=0) to be loaded in background (if not loaded yet).
Loading gig file '/home/bsmith/copy_of_Unsaved Gig File.gig'...OK
Loading gig instrument ('/home/bsmith/copy_of_Unsaved Gig File.gig',0)...OK
Caching initial samples...OK
Note the following errors:

15:46:00.979 Channel 0 lscp_set_channel_audio_type: Timeout during receive operation (errno=-4)
15:46:01.083 Channel 0 lscp_get_midi_device_info: DRIVER (errno=0)

and

15:46:02.067 Channel 0 Some channel settings could not be set. Sorry. (this is the same as the dialog that comes up)


Here's the output when qsampler crashes, which I think only happens when I close an instrument that I've unsuccessfully tried to load a new sample into:

Code: Select all

15:59:32.406 Channel 0 lscp_remove_channel: Failure during receive operation (errno=-1)
Freeing gig file from memory...lscp_client_recv: select: Interrupted system call
15:59:32.434 Client disconnecting...
15:59:32.760 Client disconnected.
15:59:32:804 Server was stopped with exit status 1.
15:59:32:960 Channel 153458032 Could not remove channel. Sorry.
QObject: Do not delete object, 'Volume Slider', during its event handler!
subgraph starting at LinuxSampler timed out (subgraph_wait_fd=10, status=0, status = Triggered)
_lscp_client_evt_proc: recv: Connection reset by peet
_lscp_client_evt_request: send: Broken pipe
_lscp_client_evt_request: send: Broken pipe
_lscp_client_evt_request: send: Broken pipe
_lscp_client_evt_request: send: Broken pipe
_lscp_client_evt_request: send: Broken pipe
_lscp_client_evt_request: send: Broken pipe
_lscp_client_evt_request: send: Broken pipe
Here's the stack trace for the crash:

Code: Select all

bsmith@rayden:~$ qsampler&
[1] 4657
bsmith@rayden:~$ *** glibc detected *** linuxsampler: double free or corruption (fasttop): 0x098adf20 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7b69624]
/lib/i686/cmov/libc.so.6(cfree+0x96)[0xb7b6b826]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb7d5b2e1]
/usr/lib/libgig.so.6(_ZNSt8_Rb_treeIPN4RIFF5ChunkES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE8_M_eraseEPSt13_Rb_tree_nodeIS2_E+0x3d)[0xb7ad949d]
/usr/lib/libgig.so.6(_ZN4RIFF4File12UnlogResizedEPNS_5ChunkE+0x12d)[0xb7ad464d]
/usr/lib/libgig.so.6(_ZN4RIFF5ChunkD2Ev+0x34)[0xb7ad4ee4]
/usr/lib/libgig.so.6(_ZN4RIFF4ListD0Ev+0xa4)[0xb7ad4fa4]
/usr/lib/libgig.so.6(_ZN4RIFF4ListD2Ev+0x3f)[0xb7ad50df]
/usr/lib/libgig.so.6(_ZN4RIFF4FileD0Ev+0x5f)[0xb7ad679f]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler3gig25InstrumentResourceManager18GigResourceManager7DestroyEPN3gig4FileEPv+0x177)[0xb7e4e067]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler3gig25InstrumentResourceManager7DestroyEPN3gig10InstrumentEPv+0x289)[0xb7e53b69]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler15ResourceManagerINS_17InstrumentManager15instrument_id_tEN3gig10InstrumentEE8HandBackEPS4_PNS_16ResourceConsumerIS4_EEb+0x262)[0xb7e6b482]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler3gig13EngineChannel27DisconnectAudioOutputDeviceEv+0x90)[0xb7e66c00]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler14SamplerChannelD0Ev+0x92)[0xb7df9262]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler7Sampler20RemoveSamplerChannelEPNS_14SamplerChannelE+0x21e)[0xb7dfb08e]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler7Sampler20RemoveSamplerChannelEj+0x32)[0xb7dfb2d2]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler10LSCPServer13RemoveChannelEj+0x41)[0xb7e30091]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_Z7yyparsePv+0x708d)[0xb7e0865d]
/usr/lib/linuxsampler/liblinuxsampler.so.1(_ZN12LinuxSampler10LSCPServer4MainEv+0x9fd)[0xb7e212cd]
/usr/lib/linuxsampler/liblinuxsampler.so.1[0xb7ece700]
/lib/i686/cmov/libpthread.so.0[0xb7c5d4c0]
/lib/i686/cmov/libc.so.6(clone+0x5e)[0xb7bdb6de]
followed by a memory map.


qsampler also unceremoniously leaves two zombie linuxsampler processes when it quits, even if it hasn't crashed and I ask it to close the server.

camobrite
Newbie
Posts: 20
Joined: Sat Mar 14, 2009 12:28 am

Re: LSCP memory problem, can't mlockall() warnings

Post by camobrite » Mon Jun 22, 2009 5:55 am

Well, it's a few months later and I just reinstalled from the latest code on the CVS. All of the problems except for the "Unable to cache sample" error are now solved, and gigedit and qsampler now save and quit gracefully. The mlockall() warning turned out to be related to user limits, so anyone getting that particular warning would do well to read up on the ulimit and the /etc/security/limits.conf file. I have opened a new thread regarding the sample caching error here. Thanks for all your help!

-camobrite

Post Reply