[genivi-dlt] DLT function interface shows strange behaviour

Helwing, Lutz Lutz_Helwing at mentor.com
Mon Jul 31 11:18:05 EDT 2017


Hello again,

I have created a patch for this issue to contribute to the discussion.
Since it looks like I am not allowed to push new branches I don't know
how to create a pull request.

Best regards
Lutz

On 31.07.2017 16:25, Helwing, Lutz wrote:
> Hello all,
> 
> i've forgot to mention another question that arose:
> 
> I'm registering the context with:
> 
> DLT_REGISTER_CONTEXT_LL_TS()
> 
> Why is the daemon trying to send a log level at all? I thought when
> DLT_REGISTER_CONTEXT_LL_TS the log level is set by the application
> itself and thus the daemon must not send one. Or am i misunderstanding
> something?
> 
> Best regards
> Lutz
> 
> On 28.07.2017 12:32, Yusuke Sato wrote:
>> Hello, Lutz,
>>
>> thank you for your detailed analysis!
>>
>>> The question is: why does the error occur at all?
>> --> I think this error occurred because test application had already been exited and the user FIFO(/tmp/dltpipes/dlt<PID>) had already been removed when dlt-daemon tried to send data.
>>
>>> What side effects could be expected when removing the "return -1"? Why does this error abort processing the read data?
>> --> In my opinion, this just changes the timing of the processing of dlt-daemon.
>>    However I'm not sure about the reason of this error handling.. It seems this has come from 1st commit of dlt-daemon.
>>    Therefore, regarding the fix, I also need opinion from DLT community.
>>
>> Thanks
>> Best regards.
>> Yusuke Sato
>>
>> Alpine Electronics, Inc.
>> yusuke-sato at apn.alpine.co.jp
>>
>> -----Original Message-----
>> From: Helwing, Lutz [mailto:Lutz_Helwing at mentor.com]
>> Sent: Friday, July 28, 2017 5:30 PM
>> To: 佐藤 裕典 Yusuke Sato <yusuke-sato at apn.alpine.co.jp>; DLT Mailing List <genivi-diagnostic-log-and-trace at lists.genivi.org>
>> Subject: Re: DLT function interface shows strange behaviour
>>
>> Hello Yusuke,
>>
>> thanks for the new input. I'm sorry it was my fault, maybe I didn't read your last mail carefully enough. And I did not think about the atexit handler and the FIFO buffer as the place where my messages could be stuck.
>>
>> It looks like your suspicion hints into the right direction: when the error in dlt-daemon occurs repeatedly  writing a 1 to /tmp/dlt triggers dlt-daemon to write the messages out piece by piece. Removing the "return -1" indeed seems to fix the issue: all messages are sent directly.
>>
>> The question is: why does the error occur at all? There are several places where dlt_daemon_user_send_log_level() could return -1 but they generate no output to the daemon's log. Debug output could be improved here. I understand that this is the place where the application context's log level is set by the daemon and it fails for some reason.
>> Why does this have to cause the daemon to stop reading data then?
>>
>> Concerning the FIFO buffer: When looking into
>> dlt_daemon_process_user_messages() (dlt_daemon.c: 1948) it looks like the data is already read and when the -1 occurs processing of the read data is stopped and the remaining data is put into the receiver buffer:
>>
>> "/* keep not read data in buffer */
>>  if (dlt_receiver_move_to_begin(receiver) == -1)"
>>
>> and this data is flushed out when new data is received in
>> dlt_receiver_receive_fd() (dlt_common.c: 2196)
>>
>> It looks like instead of the FIFO buffer my messages are more likely stuck in the receiver buffer until new data is received.
>>
>> What side effects could be expected when removing the "return -1"? Why does this error abort processing the read data?
>>
>> I could provide a patch to remove the return and improve debug output of
>> dlt_daemon_user_send_log_level() but before I want to be sure that this is not breaking anything. So please could people with more routine in DLT help me out here a little bit?
>>
>> Thank you very much.
>>
>> Kind regards
>> Lutz
>>
>> On 28.07.2017 04:13, Yusuke Sato wrote:
>>> Hello, Lutz,
>>>
>>> sorry, my idea was wrong. yesterday I did not your test application code.
>>> my assumption was based on test application keeps alive.
>>>
>>> actually there are 2 types of buffer in DLT architecture.
>>>  (1). dlt usr library buffer
>>>  (2). dlt-daemon buffer
>>>
>>> I thought that your message was stored to (1).
>>> because dlt-daemon had already been in send direct state.
>>> In this state, dlt-daemon does not store data to (2). (When dlt-daemon
>>> received log message from application, the message is directlly sent
>>> to client(DLT Viewer).)
>>>
>>> What I meant below is, somehow your message was kept into (1) buffer until exit of the application.
>>> However your test application is one-shot. Always it exits soon and
>>> flush (1) buffer at exit. (<-- atexit mechanisum is implemented in dlt
>>> usre library.)
>>>
>>> Considering above, log messages might be stuck in FIFO(default: /tmp/dlt).
>>> This will be happened when dlt-daemon stops to read data from FIFO.
>>> As you concerned, if below message is shown, dlt-daemon stops to read data from FIFO due to error..
>>>> "Jul 27 14:10:24 dem-lhelwing-ubuntu DLT[7967]: [81948.963456]~DLT~ 7967~WARNING  ~Can't send current log level as response to dlt_daemon_process_user_message_register_context for (ABCD;CTX1)"
>>>
>>> If this is correct, I think you can see the log when log is stopped by entering the command "echo 1 > /tmp/dlt" instead of starting next application.
>>> This command generate trigger dlt-daemon to receive data from FIFO again.
>>>
>>> In my opinion, we can remove "return -1;" line after output "~Can't send current log level as response to xxxxxxx" error.
>>> Then I think this issue can be fixed. (But sorry I have not tested
>>> yet..)
>>>
>>> Thanks
>>> Best regards.
>>> Yusuke Sato
>>>
>>> Alpine Electronics, Inc.
>>> yusuke-sato at apn.alpine.co.jp
>>>
>>> -----Original Message-----
>>> From: Helwing, Lutz [mailto:Lutz_Helwing at mentor.com]
>>> Sent: Friday, July 28, 2017 12:12 AM
>>> To: 佐藤 裕典 Yusuke Sato <yusuke-sato at apn.alpine.co.jp>; DLT Mailing List
>>> <genivi-diagnostic-log-and-trace at lists.genivi.org>
>>> Subject: Re: DLT function interface shows strange behaviour
>>>
>>> Hello,
>>>
>>> thanks for your quick reply. It looks like you're right i was not aware of this. When adding a sleep(1) at the end of the application after doing the logging 10 times in a loop everything looks fine.
>>>
>>> Isn't this kind of a weird and unexpected behaviour? This could mean if I write a short running application I need to be aware of this because else some messages could probably be lost?
>>>
>>> What I don't understand: when the first run of the application I see no output at some point. When running it the second time the output is there together with the new output. Does that mean the dlt-daemon is buffering the messages until some other message from any application arrives? What exactly is happening here? Could it be said that DLT misses some "flush" mechanism? Or am I just not aware of one?
>>>
>>> I have cross-checked this with another application:
>>>
>>> 1. Repeatedly  the test application without sleep() at the end until
>>>    output to DLT log incomplete
>>>
>>> 2. Run dlt-example-user -n 1 "Hello" -> output from 1. appears in DLT
>>>    log followed by output from 2.
>>>
>>> Kind regards
>>> Lutz
>>>
>>>
>>> On 27.07.2017 15:19, Yusuke Sato wrote:
>>>> Hello, Lutz,
>>>>
>>>> I guess you terminated the 1st application soon before the 2nd start.
>>>> Then log message buffered into user library buffer was outout at exit of 1st application.
>>>>
>>>> As far as I know, currently there is no automatic trigger to output messages in usr library buffer.
>>>> Normally these message is output when new message is logged.
>>>> In current case, only 2 messages are output and after that no message is logged from test application.
>>>>
>>>> So, maybe below senario happened.
>>>>
>>>> (1). Start 1st application
>>>> (2). Somehow the application cannot not send message to dlt-daemon
>>>> (3). Message is stored to own library buffer (4). Interval (Timestamp
>>>> 81948.xxx - 81975.xxx)
>>>>     --> here no trigger to output buffer (5). Kill 1st application
>>>>     --> Buffer is output to dlt-daemon (6). Start 2nd application
>>>>     --> Normally succeed to send log to dlt-daemon
>>>>
>>>> Thanks
>>>> Best regards.
>>>> Yusuke Sato
>>>>
>>>> Alpine Electronics, Inc.
>>>> yusuke-sato at apn.alpine.co.jp
>>>>
>>>> -----Original Message-----
>>>> From: genivi-diagnostic-log-and-trace
>>>> [mailto:genivi-diagnostic-log-and-trace-bounces at lists.genivi.org] On
>>>> Behalf Of Helwing, Lutz
>>>> Sent: Thursday, July 27, 2017 9:23 PM
>>>> To: DLT Mailing List
>>>> <genivi-diagnostic-log-and-trace at lists.genivi.org>
>>>> Subject: [genivi-dlt] DLT function interface shows strange behaviour
>>>>
>>>> Hi DLT community,
>>>>
>>>> I have found a problem while writing a simple DLT test programme using the function interface.
>>>>
>>>> When I run a tiny test application once the output stops at some point.
>>>> When I run it the second time the missing output from the last run is logged before the output of the current run. Notice the "rewinded"
>>>> timestamps. None of the used DLT functions return an error.
>>>> This happens just occasionally when repeatedly running the programme. No other application logs to DLT.
>>>>
>>>> See the test application's source code attached. Also attached are snippets from the DLT log that illustrate the problem and the cmake flags used for building DLT. Also attached is a snippet taken from the journal which shows dlt-daemon output with Debug information. Skip the first two successful tries here. When the error occurs the journal contains this entry:
>>>>
>>>> "Jul 27 14:10:24 dem-lhelwing-ubuntu DLT[7967]: [81948.963456]~DLT~ 7967~WARNING  ~Can't send current log level as response to dlt_daemon_process_user_message_register_context for (ABCD;CTX1)"
>>>>
>>>> The dlt-daemon is running on my local machine.
>>>> Output of "dlt-receive -a localhost" and DLT Viewer is the same.
>>>>
>>>> DLT version: 2.16.0
>>>> DLT Viewer version: 2.18.0 STABLE
>>>>
>>>> Am I doing something wrong when using the DLT library or is it a problem in DLT itself? It would be great to hear your ideas.
>>>>
>>>> Thank you very much.
>>>>
>>>> Kind regards
>>>> Lutz
>>>>
>>>> --
>>>> Mentor A Siemens Business
>>>>
>>>> Lutz Helwing, Senior Engineer, Mentor Embedded Mentor Graphics
>>>> Development (Deutschland) GmbH, Arnulfstrasse 201, 80634 Muenchen,
>>>> Germany Lutz_Helwing at mentor.com | office: +49(89)57096-297
>>>>
>>>> http://www.mentor.com
>>>>
>>>> Mentor Graphics Development (Deutschland) GmbH
>>>> Geschaeftsfuehrung: Daniel Trebes, Hanns Windele
>>>>
>>>> Handelsregister: Amtsgericht Freiburg i.Br., HRB 705237 Sitz der
>>>> Gesellschaft: Peterzeller Strasse 8, 78048 Villingen-Schwenningen
>>>> USt-Id Nummer: DE268786819
>>>>
>>>> Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
>>>>
>>>> ________________________________
>>>> ATTENTION:This e-mail and any files transmitted with it are the property of Alpine Electronics,Inc and/or its affiliates, may be privileged and/or confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not one of the named recipients or otherwise have reason to believe that you have received this e-mail in error, please notify the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing or copying of this e-mail is strictly prohibited.
>>>>
>>>> 注意:このEメールおよび添付ファイルはアルパイン株式会社および関連子会社の資産であり、法的特権を持つ情報および秘密情報を含んでいる可能性があります。また、宛先とした特定の個人もしくは団体、あるいは、それらが指定する人によってのみ、読まれることを意図しています。もし、あなたがこのEメールの意図された受信者でないなら、または、誤って送信されたものを受領したと思われる場合は、速やかに送信者へ通知の上、このEメールを削除してください。また、他の目的への利用、配布、転送、印刷、コピーは固く禁止されています。
>>>> ________________________________
>>>>
>>>
>>> --
>>> Mentor A Siemens Business
>>>
>>> Lutz Helwing, Senior Engineer, Mentor Embedded Mentor Graphics
>>> Development (Deutschland) GmbH, Arnulfstrasse 201, 80634 Muenchen,
>>> Germany Lutz_Helwing at mentor.com | office: +49(89)57096-297
>>>
>>> http://www.mentor.com
>>>
>>> Mentor Graphics Development (Deutschland) GmbH
>>> Geschaeftsfuehrung: Daniel Trebes, Hanns Windele
>>>
>>> Handelsregister: Amtsgericht Freiburg i.Br., HRB 705237 Sitz der
>>> Gesellschaft: Peterzeller Strasse 8, 78048 Villingen-Schwenningen
>>> USt-Id Nummer: DE268786819
>>>
>>> Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
>>>
>>> ________________________________
>>> ATTENTION:This e-mail and any files transmitted with it are the property of Alpine Electronics,Inc and/or its affiliates, may be privileged and/or confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not one of the named recipients or otherwise have reason to believe that you have received this e-mail in error, please notify the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing or copying of this e-mail is strictly prohibited.
>>>
>>> 注意:このEメールおよび添付ファイルはアルパイン株式会社および関連子会社の資産であり、法的特権を持つ情報および秘密情報を含んでいる可能性があります。また、宛先とした特定の個人もしくは団体、あるいは、それらが指定する人によってのみ、読まれることを意図しています。もし、あなたがこのEメールの意図された受信者でないなら、または、誤って送信されたものを受領したと思われる場合は、速やかに送信者へ通知の上、このEメールを削除してください。また、他の目的への利用、配布、転送、印刷、コピーは固く禁止されています。
>>> ________________________________
>>>
>>
>> --
>> Mentor A Siemens Business
>>
>> Lutz Helwing, Senior Engineer, Mentor Embedded Mentor Graphics Development (Deutschland) GmbH, Arnulfstrasse 201, 80634 Muenchen, Germany Lutz_Helwing at mentor.com | office: +49(89)57096-297
>>
>> http://www.mentor.com
>>
>> Mentor Graphics Development (Deutschland) GmbH
>> Geschaeftsfuehrung: Daniel Trebes, Hanns Windele
>>
>> Handelsregister: Amtsgericht Freiburg i.Br., HRB 705237 Sitz der Gesellschaft: Peterzeller Strasse 8, 78048 Villingen-Schwenningen USt-Id Nummer: DE268786819
>>
>> Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
>>
>> ________________________________
>> ATTENTION:This e-mail and any files transmitted with it are the property of Alpine Electronics,Inc and/or its affiliates, may be privileged and/or confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not one of the named recipients or otherwise have reason to believe that you have received this e-mail in error, please notify the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing or copying of this e-mail is strictly prohibited.
>>
>> 注意:このEメールおよび添付ファイルはアルパイン株式会社および関連子会社の資産であり、法的特権を持つ情報および秘密情報を含んでいる可能性があります。また、宛先とした特定の個人もしくは団体、あるいは、それらが指定する人によってのみ、読まれることを意図しています。もし、あなたがこのEメールの意図された受信者でないなら、または、誤って送信されたものを受領したと思われる場合は、速やかに送信者へ通知の上、このEメールを削除してください。また、他の目的への利用、配布、転送、印刷、コピーは固く禁止されています。
>> ________________________________
>>
> 

-- 
Mentor A Siemens Business

Lutz Helwing, Senior Engineer, Mentor Embedded
Mentor Graphics Development (Deutschland) GmbH, Arnulfstrasse 201, 80634
Muenchen, Germany
Lutz_Helwing at mentor.com | office: +49(89)57096-297

http://www.mentor.com

Mentor Graphics Development (Deutschland) GmbH
Geschaeftsfuehrung: Daniel Trebes, Hanns Windele

Handelsregister: Amtsgericht Freiburg i.Br., HRB 705237
Sitz der Gesellschaft: Peterzeller Strasse 8, 78048 Villingen-Schwenningen
USt-Id Nummer: DE268786819
	
Confidentiality Notice: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by return e-mail and destroy all
copies of the original message. 	


More information about the genivi-diagnostic-log-and-trace mailing list