Skip to content

logging: Weird output from log_strdup() #10428

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

Closed
jukkar opened this issue Oct 8, 2018 · 5 comments
Closed

logging: Weird output from log_strdup() #10428

jukkar opened this issue Oct 8, 2018 · 5 comments
Assignees
Labels
area: Logging bug The issue is a bug, or the PR is fixing a bug

Comments

@jukkar
Copy link
Member

jukkar commented Oct 8, 2018

I am seeing messages printed incorrectly when using log_strdup() in networking.
I did a quick test with following

	NET_DBG("NET_DBG foo=%s bar=%s\n", log_strdup("foo"), log_strdup("bar"));

and also added

diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c
index b8d1436499..fa02ddd581 100644
--- a/subsys/logging/log_core.c
+++ b/subsys/logging/log_core.c
@@ -521,6 +521,8 @@ char *log_strdup(const char *str)
        sdupl[LOG_STRBUF_STR_SIZE - 1] = '\0';
        sdupl[LOG_STRBUF_STR_SIZE - 2] = '~';
 
+       printk("log_strdup() output %s\n", sdupl);
+
        return sdupl;
 }

Then this is printed to console

log_strdup() output foo
log_strdup() output bar
[00:00:02.220,000] <dbg> net_ipv6: (0x08077790): net_ipv6_process_pkt: NET_DBG foo= bar=bar

So the first log_strdup() print is "lost" somewhere and not printed.

@jukkar
Copy link
Member Author

jukkar commented Oct 8, 2018

Also I had to set the CONFIG_LOG_STRDUP_BUF_COUNT to very high number 100, in order to get any print.
For example with CONFIG_LOG_STRDUP_BUF_COUNT=20 I get following output:

log_strdup() output foo
[00:00:00.420,000] <dbg> net_ipv6: (0x08076890): net_ipv6_process_pkt: NET_DBG foo=foo bar=log_strdup pool empty!

It looks like the allocated strings are not freed properly.

@jukkar
Copy link
Member Author

jukkar commented Oct 8, 2018

Forgot to mention that I did this test with native_posix board.

@nashif nashif added the bug The issue is a bug, or the PR is fixing a bug label Oct 9, 2018
@jukkar
Copy link
Member Author

jukkar commented Oct 10, 2018

Also noticed that if I set CONFIG_LOG_INPLACE_PROCESS=y, then the log_strdup pool empty! messages are no longer shown even with the default CONFIG_LOG_STRDUP_BUF_COUNT setting. But still only one of the log_strdup() strings is printed.

@nordic-krch
Copy link
Collaborator

Can you check if #10506 fixes it?

@jukkar
Copy link
Member Author

jukkar commented Oct 11, 2018

Can you check if #10506 fixes it?

Yes, with that PR applied the log output is proper. One just needs to increase the CONFIG_LOG_STRDUP_BUF_COUNT but that is another matter. Closing this one as there is already a fix.

@jukkar jukkar closed this as completed Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Logging bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

3 participants