public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Typo in assert error message causing confusion?
@ 2013-10-01  9:01 Daniel Zebralla
  2013-10-01 15:27 ` Michael Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Zebralla @ 2013-10-01  9:01 UTC (permalink / raw)
  To: ecos-discuss

From /host/infra/cyg_ass.h as well as /host/infra/cyg/infra/cyg_ass.h:

# define CYG_CHECK_DATA_PTRC( _ptr_ )                   \
         CYG_MACRO_START                                \
         if ( !cyg_check_data_ptr((void *)(_ptr_)))     \
             CYG_ASSERT_DOCALL("data pointer (" #_ptr_ ") is valid");\
         CYG_MACRO_END

# define CYG_CHECK_FUNC_PTRC( _ptr_ )                       \
         CYG_MACRO_START                                    \
         if ( !cyg_check_func_ptr((void (*)(void))(_ptr_))) \
             CYG_ASSERT_DOCALL("function pointer (" #_ptr_ ") is valid"); \
         CYG_MACRO_END

As I understand, CYG_ASSERT_DOCALL is triggered when the checked data or
function pointer is invalid. The printed message however indicates that the
checked pointer is valid. Is this an error or am I misunderstanding the
usage of CYG_ASSERT_DOCALL here?

Thanks for clarification!



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/Typo-in-assert-error-message-causing-confusion-tp245807.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Typo in assert error message causing confusion?
  2013-10-01  9:01 [ECOS] Typo in assert error message causing confusion? Daniel Zebralla
@ 2013-10-01 15:27 ` Michael Jones
  2013-10-02 11:26   ` [ECOS] " Daniel Zebralla
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Jones @ 2013-10-01 15:27 UTC (permalink / raw)
  To: Daniel Zebralla; +Cc: ecos-discuss

Daniel,

I think it is printing the assertion, not the failure.

It would be clearer if it printed:

Assertion "data pointer NNN is valid" failed

But it might be consistent with standard practice. I am not sure.

Mike



On Oct 1, 2013, at 3:01 AM, Daniel Zebralla <daniel.zebralla@zebralla-it.de> wrote:

>> From /host/infra/cyg_ass.h as well as /host/infra/cyg/infra/cyg_ass.h:
> 
> # define CYG_CHECK_DATA_PTRC( _ptr_ )                   \
>         CYG_MACRO_START                                \
>         if ( !cyg_check_data_ptr((void *)(_ptr_)))     \
>             CYG_ASSERT_DOCALL("data pointer (" #_ptr_ ") is valid");\
>         CYG_MACRO_END
> 
> # define CYG_CHECK_FUNC_PTRC( _ptr_ )                       \
>         CYG_MACRO_START                                    \
>         if ( !cyg_check_func_ptr((void (*)(void))(_ptr_))) \
>             CYG_ASSERT_DOCALL("function pointer (" #_ptr_ ") is valid"); \
>         CYG_MACRO_END
> 
> As I understand, CYG_ASSERT_DOCALL is triggered when the checked data or
> function pointer is invalid. The printed message however indicates that the
> checked pointer is valid. Is this an error or am I misunderstanding the
> usage of CYG_ASSERT_DOCALL here?
> 
> Thanks for clarification!
> 
> 
> 
> --
> View this message in context: http://sourceware-org.1504.n7.nabble.com/Typo-in-assert-error-message-causing-confusion-tp245807.html
> Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.
> 
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ECOS] Re: Typo in assert error message causing confusion?
  2013-10-01 15:27 ` Michael Jones
@ 2013-10-02 11:26   ` Daniel Zebralla
  2013-10-02 12:00     ` Stanislav Meduna
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Zebralla @ 2013-10-02 11:26 UTC (permalink / raw)
  To: ecos-discuss

I get your point of view. However, I assume that someone would like to know
what's broken instead of what would be the case if the message would have
not been displayed. If my system stops with a kernel panic and tells me
"Pointer is valid" I would be like -> oO.

As I can see inside eCos source, I'm not the only one understanding those
assertion messages this way, some examples:
CYG_ASSERT( freeret , "Couldn't free!" );
CYG_ASSERT( interr == 0, "internal lock failed!" );
CYG_ASSERT( usertmp->next != NULL, "Couldn't find message queue user" );
CYG_ASSERT( stacksize >= PTHREAD_STACK_MIN, "Inadequate stack size
supplied");
CYG_ASSERT( ticks != 0, "Zero tick count");

To sum it up:
- Some eCos developers use assertion messages to say what failed
- Some eCos developers use assertion messages to say what would have passed
This inconsistency confuses people like me, new to eCos and debugging
something which I don't fully understand yet.

Any further comments/opinions?
- Daniel



--
View this message in context: http://sourceware-org.1504.n7.nabble.com/Typo-in-assert-error-message-causing-confusion-tp245807p245957.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Re: Typo in assert error message causing confusion?
  2013-10-02 11:26   ` [ECOS] " Daniel Zebralla
@ 2013-10-02 12:00     ` Stanislav Meduna
  0 siblings, 0 replies; 4+ messages in thread
From: Stanislav Meduna @ 2013-10-02 12:00 UTC (permalink / raw)
  To: ecos-discuss

On 02.10.2013 13:26, Daniel Zebralla wrote:

> I get your point of view. However, I assume that someone would like to know
> what's broken instead of what would be the case if the message would have
> not been displayed. 

The original assert macro that is in use for decades does _not_
contain an explanatory text and outputs the expression itself.
See e.g. http://www.manpagez.com/man/3/assert/

I.e. if the programmer says "I am asserting that ptr != 0" and it
is not true, it writes that the assertion "ptr != 0" failed.

If the CYG_ASSERT follows this schema, it should definitely
print what was expected.

> If my system stops with a kernel panic and tells me
> "Pointer is valid" I would be like -> oO.

As Michael says, it should tell you something along the lines
  Assertion "Pointer is valid" failed
which makes perfect sense.

See comments at the top of host/infra/cyg_ass.h - it indeed defines
it this way.
  CYG_ASSERT( pcount > 0, "Number of probes should be > 0!" );
Unfortunaly the very same file then spoils it with
  CYG_ASSERTCLASS( p, "Object at p is broken!" );
;)

Anyway, an assertion is a developer tool catching situations
the developer thinks can never happen. As such they are not
expected to be interpreted by anyone not able to look up the
source code and investigate what exactly went wrong.

-- 
                                      Stano


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-02 12:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-01  9:01 [ECOS] Typo in assert error message causing confusion? Daniel Zebralla
2013-10-01 15:27 ` Michael Jones
2013-10-02 11:26   ` [ECOS] " Daniel Zebralla
2013-10-02 12:00     ` Stanislav Meduna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).