Subject: Re: rt_pipe_write memory allocation bug - xenomai 3.x References: <5adc97a4-014f-3a50-9109-4e574662cf7b@numalliance.com> <7f4384d6-c318-2448-99d9-bbfa7061f78e@siemens.com> <805ca3a7-a47c-98af-b014-ebf22247b2d5@numalliance.com> From: Jan Kiszka Message-ID: <575dc9ed-a7ea-a09e-6fe3-3bda3606dd27@web.de> Date: Mon, 3 Aug 2020 17:05:27 +0200 MIME-Version: 1.0 In-Reply-To: <805ca3a7-a47c-98af-b014-ebf22247b2d5@numalliance.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?St=c3=a9phane_Ancelot?= , "xenomai@xenomai.org" , Bastien COUNILH On 30.07.20 16:09, St=C3=A9phane Ancelot wrote: > > Le 30/07/2020 =C3=A0 15:25, Jan Kiszka a =C3=A9crit=C2=A0: >> On 30.07.20 11:46, St=C3=A9phane Ancelot wrote: >>> >>> Le 30/07/2020 =C3=A0 10:47, Jan Kiszka a =C3=A9crit=C2=A0: >>>> On 30.07.20 10:43, St=C3=A9phane Ancelot wrote: >>>>> >>>>> Le 30/07/2020 =C3=A0 00:08, Jan Kiszka a =C3=A9crit=C2=A0: >>>>>> On 28.07.20 15:28, St=C3=A9phane Ancelot wrote: >>>>>>> >>>>>>> Le 27/07/2020 =C3=A0 15:17, Jan Kiszka a =C3=A9crit=C2=A0: >>>>>>>> On 27.07.20 14:44, St=C3=A9phane Ancelot via Xenomai wrote: >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> Using pipe created with poolsize =3D 0, meaning all message >>>>>>>>> allocations for this pipe are performed on the Cobalt core heap. >>>>>>>>> >>>>>>>>> Unfortunately,=C2=A0 using rt_pipe_write(), when no user task is >>>>>>>>> consuming it, we discovered after almost many rt_pipe_write() >>>>>>>>> cycles (700000 at least in our process) , that the cobalt heap >>>>>>>>> and system heap seem being corrupted. >>>>>>>>> >>>>>>>>> Leading to system issues like unattended task crashes ..... >>>>>>>>> >>>>>>>> >>>>>>>> "3.x" implies both 3.1 and 3.0 are affected? >>>>>>>> >>>>>>>> Do you see a constantly growing use of system heap (leak)? If >>>>>>>> that is not the case, we might have some wrap-around issue >>>>>>>> somewhere. >>>>>>>> >>>>>>> The version we are using is=C2=A0 based on release b3e18b6d of mas= ter >>>>>>> branch. >>>>>>> >>>>>>> We don't sea system memory increasing (using top). >>>>>>> >>>>>>> Comparing it to the latest releases, we have not found any big >>>>>>> differences in xddp code . >>>>>>> >>>>>>> Using other releases , applications and compiled kernel does not >>>>>>> warranty=C2=A0 to identify it has been solved , since the memory >>>>>>> mapping to reproduce it , changes. >>>>>>> >>>>>>> For certifications reasons, we can't validate the latest source >>>>>>> code, but only cherry pick a localised hotfix in the xenomai code. >>>>>>> >>>>>>> >>>>>>>> Reproduction case would be nice. >>>>>>>> >>>>>>> It is not easy, the initial problem was reported by one of our >>>>>>> users , we spent lot of time to achieve to reproduce it in our >>>>>>> context. >>>>>>> >>>>>>> Some graphics user tasks were locking or crashing after some days >>>>>>> usage and production . >>>>>>> >>>>>>> At first,=C2=A0 we went in wrong directions in order to identify f= rom >>>>>>> where it could happen. >>>>>>> >>>>>>> In our system, we had to test each code commits back....in order >>>>>>> to isolate the problem, and understand that it was visible after >>>>>>> almost 700000 rt_pipe_write calls in our case. >>>>>>> >>>>>>> >>>>>>> As a unittest, we can provide the enclosed snippet.That is the >>>>>>> extracted code that would cause problem. >>>>>>> >>>>>> >>>>>> Under which condition does that test_pipe.cpp cause the issue? >>>>>> I've given it a quick try, and as it's late, I disabled the delay >>>>>> in the loop. That so far did not trigger an issue. Is the delay >>>>>> important? >>>>>> >>>>> The delay is not important , this is the rt_pripe_write() number of >>>>> calls, that are not consumed. >>>>> >>>>> Not easy to identify the memory leak in the heap. >>>>> >>>>> Either use a system with low memory. >>>>> >>>>> I have not tried it, but I suppose filling system memory, at a >>>>> moment it will crash it overwriting importing system data. >>>>> >>>> >>>> So, letting that test run long enough on your system will crash it? >>> >>> >>> I will have to try it. >>> >> >> I'm pretty sure we are missing at least one more variable to make this >> trigger. > > Since it overwrites some xenomai heap data, may be another task using > xenomai memory is needed. > > in my case this is a GUI task linked to some shared xenomai memory area, > and when it locks, this is doing a specific action, (listing=C2=A0 file > directory to open a file). > Would be helpful if you could extract such a workload, either from the testsuites or something crafted. However, I won't have time to look it before end of next week. Jan