Bug 6021 - errors in Unix-errorhandling
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Platform
Version: GIT MASTER
Hardware: PC Linux
: P3 normal
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2013-09-01 03:06 EDT by Joerg Dietrich
Modified: 2013-09-04 12:56:59 EDT
1 user (show)

See Also:


Attachments
patch to correct the errorhandling-errors (1.45 KB, patch)
2013-09-01 03:06 EDT, Joerg Dietrich
2nd try - now with Sys_Mkdir() instead of FS_CreatePath() (1004 bytes, patch)
2013-09-02 11:56 EDT, Joerg Dietrich

Description Joerg Dietrich 2013-09-01 03:06:23 EDT
Created attachment 3381 [details]
patch to correct the errorhandling-errors

There are two errors in function Sys_ErrorDialog() in code/sys/sys_unix.c.
This function tries to write to ~/.q3a/baseq3/crashlog.txt.
If its directory doesn't yet exist, it tries to create it and fails.
The first error is to use the filename of the file
and not its directory-name, so it creates a directory "crashlog.txt".
The second error is that it doesn't create all the parent-directories
should these be missing.
Attached is a patch which corrects these errors.
Comment 1 Tim Angus 2013-09-01 09:55:31 EDT
I'm not sure what code you're working with, but this was fixed 4 years ago in 5079343e. Reopen if you think there's still a problem.
Comment 2 Joerg Dietrich 2013-09-01 12:26:52 EDT
(In reply to comment #1)
> I'm not sure what code you're working with, but this was fixed 4 years ago
> in 5079343e. Reopen if you think there's still a problem.

It looks like Thilo Schulz changed sys_unix.c on 25-Aug-2013
and (re)introduced this bug.
Comment 3 Tim Angus 2013-09-01 17:46:52 EDT
Ah, my apologies. I was on a different branch so hadn't got that change yet.

Anyway, it looks like your fix essentially reverts Thilo's fix:

commit daf71ca50217c21edadc511feca4d4e9cf98a51a
Author: Thilo Schulz <thilo@tjps.eu>
Date:   Sun Aug 25 12:00:30 2013 +0200

    Fix recursive crash when home path cannot be created

I guess he means that FS_CreatePath fatals when it fails which is obviously bad when you're already handling a crash. I guess the solution is to use Sys_Mkdir(dirpath)?
Comment 4 Joerg Dietrich 2013-09-02 10:31:35 EDT
(In reply to comment #3)
> Ah, my apologies. I was on a different branch so hadn't got that change yet.
> 
> Anyway, it looks like your fix essentially reverts Thilo's fix:
> 
> commit daf71ca50217c21edadc511feca4d4e9cf98a51a
> Author: Thilo Schulz <thilo@tjps.eu>
> Date:   Sun Aug 25 12:00:30 2013 +0200
> 
>     Fix recursive crash when home path cannot be created
> 
> I guess he means that FS_CreatePath fatals when it fails which is obviously
> bad when you're already handling a crash. I guess the solution is to use
> Sys_Mkdir(dirpath)?

This makes sense! But Sys_Mkdir() only creates the specified directory.
It doesn't do recursion and it doesn't remove the the filename-part
of the path. But it shouldn't be to difficult to implement this
functionality with Sys_Mkdir().
Comment 5 Joerg Dietrich 2013-09-02 11:56:18 EDT
Created attachment 3382 [details]
2nd try - now with Sys_Mkdir() instead of FS_CreatePath()
Comment 6 Tim Angus 2013-09-04 12:56:59 EDT
Applied in 4626947. Thanks.