Nп/п : 16 из 100
 От   : Ralf Fassel                         2:5075/128        15 сен 23 11:11:01
 К    : The Natural Philosopher                               15 сен 23 12:13:02
 Тема : Re: Weird code crash
----------------------------------------------------------------------------------
                                                                                 
@MSGID: <ygail8biyxm.fsf@akutech.de> 1727fb9c
@REPLY: 4@dont-email.me> 334c88f5
@REPLYADDR Ralf Fassel <ralfixx@gmx.de>
@REPLYTO 2:5075/128 Ralf Fassel
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: <ygail8biyxm.fsf@akutech.de>
@RFC-References: 1@dont-email.me>
<ygamsxoixhx.fsf@akutech.de>4@dont-email.me>
@TZUTC: 0200
@PID: Gnus/5.13 (Gnus v5.13) Emacs/27.2
(gnu/linux)
@TID: FIDOGATE-5.12-ge4e8b94
* The Natural Philosopher <tnp@invalid.invalid>
| On 14/09/2023 16:29, Ralf Fassel wrote:
| > * The Natural Philosopher <tnp@invalid.invalid>
| > | One possibility is that it is opening and reading a file at the
| > | precise time another process is writing it...in both cases the read
| > | and write
| > | operations are atomic and done with C code.
| >>
| > | READ
| > | ====
| > | fp=fopen(fullname, "r");
| > | len=fread(filbuf,1,255,fp); // read entire file
| > Check for fp != NULL is missing here in this example code before
| > fread().  If this also in the production version, it might be a problem
| > if the file is not accessible for any reason.
| > R`
| Ralf, I already put that in this morning, re compiled the code and
| after an hour, it crashed again.
>
| The filename is built by scanning a directory so the filename must exist.

That assumption does not hold.  Since scanning and opening are separated
by a time gap (albeit a `small` one), there is a non-zero chance that
the file vanished between scan and open.

Further possibilities:
- how is `filbuf` used after the fread()?  If you use it as C-string, make
  sure it is 0-terminated (fread() won`t do that for you).  Maybe use
  fgets(3) instead?

| I am leaning towards possibly a cracked solder joint or board.

Well, since the Raspi is cheap, that should be easily checked by simply
using another one.  I bet 1 beer that it is *not* a cracked board, since
with that many more processes should run into trouble, not only this
particular one.

R` (.sig not from me .-)
-- 
echo `[  bottles of beer]sa[  bottle of beer]sb[  take one down, pass it around
]sd[ on the wall]sc[no more]se99snlc[lalnpsnPplalnp1-snpldPln1=ylnpsnPp[]pst
ln0 --- Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 * Origin: usenet.network (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх