Nп/п : 31 из 100
 От   : The Natural Philosopher             2:5075/128        15 сен 23 13:18:55
 К    : Richard Kettlewell                                    15 сен 23 15:21:02
 Тема : Re: Weird code crash
----------------------------------------------------------------------------------
                                                                                 
@MSGID: 1@dont-email.me> 1c2177d3
@REPLY: <wwvjzsrk83f.fsf@LkoBDZeT.terraraq.uk>
b0bc3425
@REPLYADDR The Natural Philosopher
<tnp@invalid.invalid>
@REPLYTO 2:5075/128 The Natural Philosopher
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: 1@dont-email.me>
@RFC-References: 1@dont-email.me>
<ygamsxoixhx.fsf@akutech.de> 4@dont-email.me> <ygail8biyxm.fsf@akutech.de>
1@dont-email.me> <wwvjzsrk83f.fsf@LkoBDZeT.terraraq.uk>
@TZUTC: 0100
@PID: Mozilla/5.0 (X11; Linux x86_64; rv:102.0)
Gecko/20100101 Thunderbird/102.15.1
@TID: FIDOGATE-5.12-ge4e8b94
On 15/09/2023 12:07, Richard Kettlewell wrote:
> The Natural Philosopher <tnp@invalid.invalid> writes:
>> dir = opendir(VOLATILE_DIR);
>>
>> if(!dir)
>> return;
>> while ((dp = readdir (dir)) != NULL)
>> {
>> filename=dp->d_name;
>> // skip known bollocks
>> if(!strcmp(filename, "." ) || !strcmp(filename, ".." )
>> || !strcmp(filename, "relays.dat" ))
>> continue;
>> // construct full path
>> sprintf(fullname,"%s/%s",VOLATILE_DIR,filename);

> Possible write overrun here.
The filenames never change length.


>> stat(fullname,&stats);// get tfile times
>> if(time(NULL)-stats.st_ctime >1800) // skip files older than half an hour
>> continue;
>> len=strlen(filename);
>> if(strncmp(filename+len-4, ".dat",4)) // .dat file but not relays.dat
>> continue;

> Possible read under-run here. (But if it crashes then you`d expect
> SIGSEGV rather than SIGABRT, so that`s probably not the issue.)

>> fp=fopen(fullname, "r");
>> if(fp==0) //file has disappeared?
>> continue;
>> len=fread(filbuf,1,255,fp);

> I don`t think the declaration of filbuf has been posted, so there`s a
> possible write overrun if it`s less than 255 bytes.


char filbuf[256];
char fullname[256];

The fullname is of the form

/var/www/data/volatile/192.168.0.xx.dat

There are no other files apart from `relay.dat` in that directory.

I mean you are all throwing noob bugs at me. Yes, in 1984 that`s the 
sort of shit I used to write. Not these days.

I have a drawer full of T shirts marked `buffer overrun` `alloc without 
free` `fopen without fclose`.

The fact is the  memory footprint does not increase.  So there are no 
obvious or simple memory leaks.

I`ve absolutely covered every error case mentioned here in the one case 
of the files that get written and read every few seconds.

It occurs to me that this behaviour started when I made it autoboot 
under systemd as well.

Since the consensus seems to be it isn`t hardware, or file corruption, I 
am trying it launched manually to see if it crashes or not.

Systemd does seem to wrap things in resource limits, and start with a 
slightly different ENV although I cant see that any are being exceeded.

If it wasn`t a daemon I would expect it to segfault and show that on 
screen. I could run it without daemonising it as well.

So lots of options to try.

As well as soft debuggers.

-- 
"It is dangerous to be right in matters on which the established 
authorities are wrong."

- Voltaire, The Age of Louis XIV

 --- Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
 * Origin: A little, after lunch (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    
                                                                                
В этой области больше нет сообщений.

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