This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Nested mutex problem (fdlock in fd.cxx)


Hi.

I have found a small problem with mutex 'fdlock' in
'io/fileio/current/src/fd.cxx' for one particular case. It seems that it is
possible to create nested mutex lock case in a file system implementation.
Specifically, call to close() function locks 'fdlock', which then may lead
to another lock by calling 'printf' in lower layers (within the particular
file system implementation). This is because 'printf' may get to
cyg_fp_get() function, which is also locking 'fdlock'. Unfortunately, eCos
does not support nested mutexes.

It may sound odd that 'printf' is used within file system functions.
Nevertheless, it may be quite useful for reporting errors in low level
functions (egg. bad block warning, write protect notification, etc.). It is
worth to mention that I am debugging some proprietary file system under
eCos.


Please, take a look at the following stack backtrace (simplified for easier
reading):

#0  cyg_assert_fail
#1  Cyg_Mutex::lock at mutex.cxx:237
#2  cyg_fp_get at fd.cxx:258    <- trying to lock fdlock for 2nd time
#3  readwrite at io.cxx:87
#4  write at io.cxx:148
#5  Cyg_StdioStream::flush_output_unlocked at io.inl:131
#6  Cyg_StdioStream::write at stream.cxx:673
#7  vfnprintf at vfnprintf.cxx:265
#8  printf at printf.cxx:66
#9  (myfilesystem_write_sector)
#10 (myfilesystem_flush_buffer)
#11 (myfilesystem_fo_close)
#12 fp_ucount_dec at fd.cxx:149
#13 fd_close at fd.cxx:174
#14 cyg_fd_free at fd.cxx:238   <- fdlock locked (1st time) prior to call to
fd_close.
#15 close at io.cxx:172
(...)


Due to the lack of time, I still did not switch to latest eCos 2.0 on CVS.
Instead, I am using eCos CVS tree from February (I think). Therefore, I
would apologize for asking this in the case that the issue has been already
solved. Anyway, I checked the eCos 2.0 and didn't notice anything new
related to my problem.

I would appreciate any advice on how to avoid this problem.

Thanks and best regards,
Jura



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]