public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] system ASSERT problem
@ 2007-03-21 10:09 Tomasz Kutyła
  2007-03-21 10:14 ` Andrew Lunn
  0 siblings, 1 reply; 11+ messages in thread
From: Tomasz Kutyła @ 2007-03-21 10:09 UTC (permalink / raw)
  To: ecos-discuss

Hi,

I got strange problem with my application. When I compile system with 
global compiler flags

-ml -m4 -O2 -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef 
-Woverloaded-virtual -ggdb -ffunction-sections -fdata-sections -fno-rtti 
-fno-exceptions -fvtable-gc -finit-priority -save-temps

I got info on terminal:

ASSERT FAIL: <3>mcard.c[193]int mcard_write_bmask() Valid card handler 
required
ASSERT FAIL: mcard.c             [ 193] int 
mcard_write_bmask()                                                                              
Valid card handler required

But when I remove '-O2' flag the problems doesn't occur. What can be the 
problem???

Thanks in advance for your help;)

Regards

Tommy

-- 
Tomasz Kutyla, Design Engineer
MARP Electronic Sp. z o.o., ul. Pachonskiego 9, 31-223 Krakow
tel. +48 12 415-87-29 (ext. 35), mob.: +48 693 112 191
fax +48 12 415-86-80

e-mail: tkutyla@marp.pl; http://www.marp.pl


-- 
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] 11+ messages in thread
* Re:  [ECOS] system ASSERT problem
@ 2007-03-21 15:47 bob.koninckx
  2007-03-21 16:02 ` Tomasz Kutyla
  0 siblings, 1 reply; 11+ messages in thread
From: bob.koninckx @ 2007-03-21 15:47 UTC (permalink / raw)
  To: Kurt Siedenburg, Tomasz      Kutyła, ecos-discuss


>-----Original Message-----
>From: Kurt Siedenburg [mailto:kurt.siedenburg@vicom.com]
>Sent: Wednesday, March 21, 2007 11:07 AM
>To: 'Tomasz KutyÂła', ecos-discuss@ecos.sourceware.org
>Subject: RE: [ECOS] system ASSERT problem
>
>My best guess is that due to advanced compiler optimization the compiler determines that the line
>   e = mcard_open(&mcard);
>either always sets mcard.mcard_hdl to NULL.
>Or the whole call to mcard_open gets optimized away.

We did not see the code of mcard_open. Does it actually change the value of mcard.mcard_hdl? If it doesn't, the assert just does what it is supposed to do.

>  Kurt

Bob

>
>-----Original Message-----
>From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Tomasz Kutyla
>Sent: Wednesday, March 21, 2007 3:32 AM
>To: ecos-discuss@ecos.sourceware.org
>Subject: Re: [ECOS] system ASSERT problem
>
>
>>> I got strange problem with my application. When I compile system with 
>>> global compiler flags
>>>
>>> -ml -m4 -O2 -Wall -Wpointer-arith -Wstrict-prototypes -Winline 
>>> -Wundef -Woverloaded-virtual -ggdb -ffunction-sections 
>>> -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority 
>>> -save-temps
>>>
>>> I got info on terminal:
>>>
>>> ASSERT FAIL: <3>mcard.c[193]int mcard_write_bmask() Valid card 
>>> handler required
>>> ASSERT FAIL: mcard.c             [ 193] int 
>>> mcard_write_bmask()                                                         
>>> Valid card handler required
>>>
>>> But when I remove '-O2' flag the problems doesn't occur. What can be 
>>> the problem???
>>>     
>>
>> There is no mcard.c in the repository, so i guess it is something you 
>> have added. Without the code it is hard to guess what is happening.
>Below is the code that generates the ASSERT:
>
>int mcard_write_bmask(mcard_t *card)
>{
>   CYG_CHECK_DATA_PTR(card, "valid card pointer required");
>   CYG_CHECK_DATA_PTR(card->bmask, "valid mask pointer required");
>   CYG_ASSERT(card->mcard_hdl,"Valid card handler required");
>
>   if( !card->mcard_hdl ) return -EINVAL;
>   if( !card->bmask ) return -EINVAL;
>
>   int e;
>   e = mcard_verify_card(card);
>   if( e ) return e;
>
>   e = cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_LOCK,0,0);
>   if( e ) return -EIO;
>
>   cyg_uint32 address = card->header.bmask_offset;
>    cyg_uint32 len = sizeof(cyg_uint32);
>    
>cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_WRITE_POS,&address,&len);
>    len = card->header.bmask_size;
> 
>    e = cyg_io_write(card->mcard_hdl,card->bmask,&len);
>   
>   cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_UNLOCK,0,0);
>
>   if( e ) return -EIO;
>
>   return ENOERR;
>}
>
>**************************
>
>and the mcard_write_bmask function is called from function below:
>
>typedef struct mcard_t
>{
>   cyg_io_handle_t   mcard_hdl;
>   mcard_header_t    header;
>   mcard_bmask_t    *bmask;
>   cyg_uint8         opened;
>} mcard_t;
>
>int I::formatCard()
>{
>   int e;
>
>   mcard_t mcard;
>   mcard.mcard_hdl = 0;
>   e = mcard_open(&mcard);
>   if( e ) return -1;
>
>   MCARD_PRINT_HEADER(&mcard.header);
>
>   CLEAR_BUF(mcard.bmask,mcard.header.bmask_size);
>   e = mcard_write_bmask(&mcard);
>   if( e ) return e;
>
>   MCARD_PRINT_BMASK(&mcard);
>
>   mcard_pdata_t pdata;
>   CLEAR_BUF(&pdata,sizeof(mcard_pdata_t))
>   e = mcard_write_pdata(&mcard, &pdata);
>   if( e ) return e;
>
>   MCARD_PRINT_PDATA(&pdata);
>
>   return 0;
>}
>
>--
>Tomasz Kutyla, Design Engineer
>MARP Electronic Sp. z o.o., ul. Pachonskiego 9, 31-223 Krakow tel. +48 12 415-87-29 (ext. 35), mob.: +48 693 112 191 fax +48 12 415-86-80
>
>e-mail: tkutyla@marp.pl; http://www.marp.pl
>
>
>--
>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
>
>



-- 
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] 11+ messages in thread
* Re:  [ECOS] system ASSERT problem
@ 2007-03-21 17:23 bob.koninckx
  2007-03-26 15:39 ` Tomasz Kutyla
  0 siblings, 1 reply; 11+ messages in thread
From: bob.koninckx @ 2007-03-21 17:23 UTC (permalink / raw)
  To: Tomasz Kutyla, bob.koninckx; +Cc: Kurt Siedenburg, ecos-discuss


>-----Original Message-----
>From: Tomasz Kutyla [mailto:tkutyla@marp.pl]
>Sent: Wednesday, March 21, 2007 12:01 PM
>To: bob.koninckx@o-3s.com
>Cc: 'Kurt Siedenburg', ecos-discuss@ecos.sourceware.org
>Subject: Re: [ECOS] system ASSERT problem
>
>Below is the code for mcard_open:
>
>int mcard_open(mcard_t *card)
>{
>   CYG_CHECK_DATA_PTR(card, "Valid card pointer required");
>
>   if( !card ) return -EINVAL;
>
>   if( card->opened ) return 0;
>
>   card->bmask = NULL;
>   card->mcard_hdl = 0;
>
>   int e;
>
>   e = cyg_io_lookup ("/dev/i2c/m14c64", &card->mcard_hdl);
>
>   if( !card->mcard_hdl ) return e;

This could be it. If e == 0 and mcard->mcard_hdl == 0 (which probably means there's something wrong with your driver), you'll get the assert afterwards.

>
>   e = mcard_read_header(card);
>   if( e ) return e;
>   
>   MCARD_PRINT_HEADER(&card->header);
>
>   e = mcard_read_bmask(card);
>   if( e ) return e;
>
>   MCARD_PRINT_BMASK(card);
>
>   card->opened = true;
>
>   return 0;
>}
>
>Tomasz
>
>
>
>bob.koninckx@o-3s.com napisaÂł(a):
>>> -----Original Message-----
>>> From: Kurt Siedenburg [mailto:kurt.siedenburg@vicom.com]
>>> Sent: Wednesday, March 21, 2007 11:07 AM
>>> To: 'Tomasz KutyÂła', ecos-discuss@ecos.sourceware.org
>>> Subject: RE: [ECOS] system ASSERT problem
>>>
>>> My best guess is that due to advanced compiler optimization the compiler determines that the line
>>>   e = mcard_open(&mcard);
>>> either always sets mcard.mcard_hdl to NULL.
>>> Or the whole call to mcard_open gets optimized away.
>>>     
>>
>> We did not see the code of mcard_open. Does it actually change the value of mcard.mcard_hdl? If it doesn't, the assert just does what it is supposed to do.
>>
>>   
>>>  Kurt
>>>     
>>
>> Bob
>>
>>   
>>> -----Original Message-----
>>> From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Tomasz Kutyla
>>> Sent: Wednesday, March 21, 2007 3:32 AM
>>> To: ecos-discuss@ecos.sourceware.org
>>> Subject: Re: [ECOS] system ASSERT problem
>>>
>>>
>>>     
>>>>> I got strange problem with my application. When I compile system with 
>>>>> global compiler flags
>>>>>
>>>>> -ml -m4 -O2 -Wall -Wpointer-arith -Wstrict-prototypes -Winline 
>>>>> -Wundef -Woverloaded-virtual -ggdb -ffunction-sections 
>>>>> -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority 
>>>>> -save-temps
>>>>>
>>>>> I got info on terminal:
>>>>>
>>>>> ASSERT FAIL: <3>mcard.c[193]int mcard_write_bmask() Valid card 
>>>>> handler required
>>>>> ASSERT FAIL: mcard.c             [ 193] int 
>>>>> mcard_write_bmask()                                                         
>>>>> Valid card handler required
>>>>>
>>>>> But when I remove '-O2' flag the problems doesn't occur. What can be 
>>>>> the problem???
>>>>>     
>>>>>         
>>>> There is no mcard.c in the repository, so i guess it is something you 
>>>> have added. Without the code it is hard to guess what is happening.
>>>>       
>>> Below is the code that generates the ASSERT:
>>>
>>> int mcard_write_bmask(mcard_t *card)
>>> {
>>>   CYG_CHECK_DATA_PTR(card, "valid card pointer required");
>>>   CYG_CHECK_DATA_PTR(card->bmask, "valid mask pointer required");
>>>   CYG_ASSERT(card->mcard_hdl,"Valid card handler required");
>>>
>>>   if( !card->mcard_hdl ) return -EINVAL;
>>>   if( !card->bmask ) return -EINVAL;
>>>
>>>   int e;
>>>   e = mcard_verify_card(card);
>>>   if( e ) return e;
>>>
>>>   e = cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_LOCK,0,0);
>>>   if( e ) return -EIO;
>>>
>>>   cyg_uint32 address = card->header.bmask_offset;
>>>    cyg_uint32 len = sizeof(cyg_uint32);
>>>    
>>> cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_WRITE_POS,&address,&len);
>>>    len = card->header.bmask_size;
>>>
>>>    e = cyg_io_write(card->mcard_hdl,card->bmask,&len);
>>>   
>>>   cyg_io_set_config(card->mcard_hdl,CYG_IO_SET_CONFIG_CARD_UNLOCK,0,0);
>>>
>>>   if( e ) return -EIO;
>>>
>>>   return ENOERR;
>>> }
>>>
>>> **************************
>>>
>>> and the mcard_write_bmask function is called from function below:
>>>
>>> typedef struct mcard_t
>>> {
>>>   cyg_io_handle_t   mcard_hdl;
>>>   mcard_header_t    header;
>>>   mcard_bmask_t    *bmask;
>>>   cyg_uint8         opened;
>>> } mcard_t;
>>>
>>> int I::formatCard()
>>> {
>>>   int e;
>>>
>>>   mcard_t mcard;
>>>   mcard.mcard_hdl = 0;
>>>   e = mcard_open(&mcard);
>>>   if( e ) return -1;
>>>
>>>   MCARD_PRINT_HEADER(&mcard.header);
>>>
>>>   CLEAR_BUF(mcard.bmask,mcard.header.bmask_size);
>>>   e = mcard_write_bmask(&mcard);
>>>   if( e ) return e;
>>>
>>>   MCARD_PRINT_BMASK(&mcard);
>>>
>>>   mcard_pdata_t pdata;
>>>   CLEAR_BUF(&pdata,sizeof(mcard_pdata_t))
>>>   e = mcard_write_pdata(&mcard, &pdata);
>>>   if( e ) return e;
>>>
>>>   MCARD_PRINT_PDATA(&pdata);
>>>
>>>   return 0;
>>> }
>>>
>>> --
>>> Tomasz Kutyla, Design Engineer
>>> MARP Electronic Sp. z o.o., ul. Pachonskiego 9, 31-223 Krakow tel. +48 12 415-87-29 (ext. 35), mob.: +48 693 112 191 fax +48 12 415-86-80
>>>
>>> e-mail: tkutyla@marp.pl; http://www.marp.pl
>>>
>>>
>>> --
>>> 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
>>>
>>>
>>>     
>>
>>
>>
>>   
>
>-- 
>Tomasz Kutyla, Design Engineer
>MARP Electronic Sp. z o.o., ul. Pachonskiego 9, 31-223 Krakow
>tel. +48 12 415-87-29 (ext. 35), mob.: +48 693 112 191
>fax +48 12 415-86-80
>
>e-mail: tkutyla@marp.pl; http://www.marp.pl
>
>



-- 
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] 11+ messages in thread

end of thread, other threads:[~2007-03-26  6:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21 10:09 [ECOS] system ASSERT problem Tomasz Kutyła
2007-03-21 10:14 ` Andrew Lunn
2007-03-21 10:32   ` Tomasz Kutyła
2007-03-21 13:36     ` Andrew Lunn
2007-03-21 16:00       ` Tomasz Kutyla
2007-03-21 16:03         ` Andrew Lunn
2007-03-21 15:09     ` Kurt Siedenburg
2007-03-21 15:47 bob.koninckx
2007-03-21 16:02 ` Tomasz Kutyla
2007-03-21 17:23 bob.koninckx
2007-03-26 15:39 ` Tomasz Kutyla

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).