Skip to content
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

[DO NOT MERGE] mm/mm_heap: fix crash when CONFIG_DEBUG_MM_INFO is enabled #5969

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abhishek-samsung
Copy link
Contributor

When CONFIG_DEBUG_MM_INFO, dbg is used to print few logs during task clean up stage. This causes issue as during task clean up the stdout stream related semaphore is uninitialized in the func lib_stream_release , but the same sem is used later for dbg logs. Thus, this results in assert failure in lib_filesem.c as the error number we get when taking sem on an invalid sem is EINVAL

So, use mllvdbg instead of mvdbg

When CONFIG_DEBUG_MM_INFO, dbg is used to print few logs during
task clean up stage. This causes issue as during task clean up
the stdout stream realted semaphore is uninitialized in the func
lib_stream_release , but the same sem is used later for dbg logs.
Thus, this results in assert failure in lib_filesem.c as the error
number we get when taking sem on an invalid sem is EINVAL

So, use mllvdbg instead of mvdbg

Signed-off-by: Abhishek Akkabathula <a.akkabathul@samsung.com>
@sunghan-chang
Copy link
Contributor

@abhishek-samsung How about log mixed with lldvg?

@abhishek-samsung
Copy link
Contributor Author

@abhishek-samsung How about log mixed with lldvg?

Hello @sunghan-chang , mixed logs can happen because of this. But this will avoid the crash (caused by assert). Will discuss this with my team and will update you if we find a different approach.

@abhishek-samsung abhishek-samsung changed the title mm/mm_heap: fix crash when CONFIG_DEBUG_MM_INFO is eanbled [DO NOT MERGE] mm/mm_heap: fix crash when CONFIG_DEBUG_MM_INFO is eanbled Oct 25, 2023
@abhishek-samsung abhishek-samsung changed the title [DO NOT MERGE] mm/mm_heap: fix crash when CONFIG_DEBUG_MM_INFO is eanbled [DO NOT MERGE] mm/mm_heap: fix crash when CONFIG_DEBUG_MM_INFO is enabled Oct 25, 2023
@abhishek-samsung
Copy link
Contributor Author

A bit more context, this issue was introduced by the PR #5742 , before this there was no dependency on stdout file sem for dbg.

@ewoodev
Copy link
Contributor

ewoodev commented Oct 30, 2023

@abhishek-samsung How about remove dependency stdout sem and add syslog buffer for only dbg.
That way #5742 this log mix issue can be solved by uart sem.

The uart write is getting argument buffer and buffer size and takes sem per-buffer. but dbg has not buffer, so I think, occerd log mix issue.
Therefore, if add dbg buffer, we can seperate printf(stdout) and dbg.

@abhishek-samsung
Copy link
Contributor Author

@abhishek-samsung How about remove dependency stdout sem and add syslog buffer for only dbg. That way #5742 this log mix issue can be solved by uart sem.

The uart write is getting argument buffer and buffer size and takes sem per-buffer. but dbg has not buffer, so I think, occerd log mix issue. Therefore, if add dbg buffer, we can seperate printf(stdout) and dbg.

I think the initial design for dbg was to not use any buffering.

* [a-z]dbg() -- Outputs messages to the console similar to printf() except
* that the output is not buffered. The first character indicates the
* system system (e.g., n=network, f=filesystem, etc.). If the first

also, do you mean we will need to maintain two different buffers? Again we need some kind of synchronization between them when outputting right?

@sunghan-chang
Copy link
Contributor

@abhishek-samsung If dbg does not cause log mixed with printf log, then we don't need PR #5742 and any buffer. What we want is just one. No log mixed with printf and dbg. For this, we applied the same sem for both.

@sunghan-chang
Copy link
Contributor

As I remember, initially dbg and printf do not mix logs. dbg is just debugging message so that we don't need to use different path to print logs. Only lldbg is necessary for different path at specific state (assert or before uart console init)
I think we can change like this

#ifdef config_debug_error
#define dbg() printf()
#else
#define dbg()
#endif

#ifdef config_debug_verbose
#define vdbg() printf()
#else
#define vdbg()
#endif

#ifdef config_debug_info....
....

@ewoodev
Copy link
Contributor

ewoodev commented Oct 30, 2023

This chage need prerepuisites as below

Do not use dbg case of after called sched_lock() and irqsave().
lib_printf can be context changed. but dbg is used in scheduling code, so that this also must be chaged.

If we will change, please also refer to this

@abhishek-samsung
Copy link
Contributor Author

@sunghan-chang and @ewoodev, my team is looking into this. Please give us some time to do the analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants