Camera crash on startup - investigation. - page 9 - General Discussion and Assistance - CHDK Forum

Camera crash on startup - investigation.

  • 112 Replies
  • 26803 Views
*

Offline reyalp

  • ******
  • 12650
Re: Camera crash on startup - investigation.
« Reply #80 on: 01 / March / 2014, 22:05:37 »
Advertisements
The FsIoNotify call in _Close will also ignore the file handle if it is not in the list, so replacing _Close with _close is not strictly necessary.
Having said that, mixing function versions might lead to confusion in the future so perhaps it's better to replace all of them (_Open, _Close, _Read and _Write).
Agreed. _Close should be safe, I'm not 100% sure about _Write. e.g.:
Canon firmware calls _Close, gets preempted before FsIoNotify call
CHDK calls _open, gets the same FD number
CHDK calls _Write which still sees the FD in it's FsIoNotify stuff
I'm not sure if this can actually happen (or would be a problem if it did), but it would be probably be better to just use all calls without FsIoNotify.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3156
    • Photos
Re: Camera crash on startup - investigation.
« Reply #81 on: 01 / March / 2014, 22:48:21 »
The FsIoNotify call in _Close will also ignore the file handle if it is not in the list, so replacing _Close with _close is not strictly necessary.
Having said that, mixing function versions might lead to confusion in the future so perhaps it's better to replace all of them (_Open, _Close, _Read and _Write).
Agreed. _Close should be safe, I'm not 100% sure about _Write. e.g.:
Canon firmware calls _Close, gets preempted before FsIoNotify call
CHDK calls _open, gets the same FD number
CHDK calls _Write which still sees the FD in it's FsIoNotify stuff
I'm not sure if this can actually happen (or would be a problem if it did), but it would be probably be better to just use all calls without FsIoNotify.

Good point.

I'll see if I can fix finsig_dryos to differentiate between _Read/_read and _Write/_write correctly.
That way we can test the various options.

Phil.

Edit: Hmmm. There does not appear to be a version of 'Read/read' that calls any FsIoNotify function, in the dumps I've looked at. So we may not need to worry about this one.
« Last Edit: 02 / March / 2014, 18:59:54 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline reyalp

  • ******
  • 12650
Re: Camera crash on startup - investigation.
« Reply #82 on: 02 / March / 2014, 19:17:44 »
Edit: Hmmm. There does not appear to be a version of 'Read/read' that calls any FsIoNotify function, in the dumps I've looked at. So we may not need to worry about this one.
Yeah, I'm pretty sure Read has always just called read() directly.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 12650
Re: Camera crash on startup - investigation.
« Reply #83 on: 12 / March / 2014, 00:44:08 »
I checked this in for dryos only in changeset 3377

Dryos only because I'm not 100% confident the _open stubs are necessarily correct in the vxworks ports, and vxworks doesn't generally suffer from the problem.

I have not addressed the Write vs write issue.
Don't forget what the H stands for.


*

Offline philmoz

  • *****
  • 3156
    • Photos
Re: Camera crash on startup - investigation.
« Reply #84 on: 12 / March / 2014, 03:37:48 »
I have not addressed the Write vs write issue.

I've been looking at this; but I'm currently having intermittent problems with config files not being saved.

I don't know whether it's caused by using _open for files to be written or using _write to update the files.

I've had one case where the config file was not created when it did not exist, so I'm wondering if it's a problem with using _open.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline reyalp

  • ******
  • 12650
Re: Camera crash on startup - investigation.
« Reply #85 on: 12 / March / 2014, 23:34:51 »
I've been looking at this; but I'm currently having intermittent problems with config files not being saved.

I don't know whether it's caused by using _open for files to be written or using _write to update the files.

I've had one case where the config file was not created when it did not exist, so I'm wondering if it's a problem with using _open.

Phil.
Ugh.

Might be worth writing a torture test that spams file operations and checks the results. I'll try to do this if you don't get to it first.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3156
    • Photos
Re: Camera crash on startup - investigation.
« Reply #86 on: 12 / March / 2014, 23:41:31 »
I've been looking at this; but I'm currently having intermittent problems with config files not being saved.

I don't know whether it's caused by using _open for files to be written or using _write to update the files.

I've had one case where the config file was not created when it did not exist, so I'm wondering if it's a problem with using _open.

Phil.
Ugh.

Might be worth writing a torture test that spams file operations and checks the results. I'll try to do this if you don't get to it first.

Still trying to come up with a reproducible scenario.

It's happened on four different cameras; but the symptoms are very strange.
When I started testing the _open/_write changes I noticed that some config settings were not being saved.
One one camera the CCHDK4.CFG settings did not update, on another the OSD__4.CFG settings would not be saved, on a third camera both failed to save.

I reverted to the old code and it started working; but when I put back the new code the config files then started saving correctly.

At the moment I have all four cameras working with the new code - and absolutely no idea what caused it or how to make it happen again.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline reyalp

  • ******
  • 12650
Re: Camera crash on startup - investigation.
« Reply #87 on: 15 / March / 2014, 01:27:28 »
From another thread
OK, that makes sense (except the part where Canon didn't protect it with a semaphore or something...)
Looking at the filewrite stuff, there is some functions that normally take a semaphore before file operations and release after. On D10 these are sub_FF854354 and sub_FF8543A4 (both in FileSem.c)

This might provide an alternative approach.
Don't forget what the H stands for.


*

Offline srsa_4c

  • ******
  • 4242
Re: Camera crash on startup - investigation.
« Reply #88 on: 19 / March / 2014, 14:41:04 »
When I started testing the _open/_write changes I noticed that some config settings were not being saved.
It's not just you, I'm getting this too (a3400, current trunk). Power on -> set user menu to [off] -> exit CHDK menu -> power off -> power on -> user menu still there.

*

Offline reyalp

  • ******
  • 12650
Re: Camera crash on startup - investigation.
« Reply #89 on: 19 / March / 2014, 16:24:06 »
When I started testing the _open/_write changes I noticed that some config settings were not being saved.
It's not just you, I'm getting this too (a3400, current trunk). Power on -> set user menu to [off] -> exit CHDK menu -> power off -> power on -> user menu still there.
Can you try the exact same scenario without the open change (build 3376 or earlier)? I wouldn't be surprised if there was some other weirdness in config saving, possibly depending on whether you have exited alt mode before powering off.
Don't forget what the H stands for.

 

Related Topics