os.rename causes crash when dest. path > 31 characters - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum

os.rename causes crash when dest. path > 31 characters

  • 23 Replies
  • 7374 Views
*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: os.rename causes crash when dest. path > 31 characters
« Reply #10 on: 14 / July / 2021, 13:13:06 »
Advertisements
Testing activity isn't overwhelming (no-one else has downloaded the test script to date).
a3200, ixus115 (r47): name limit 31, path+name limit 59
All lifetime is a loan from eternity.

*

Offline blackhole

  • *****
  • 946
  • A590IS 101b
    • Planetary astrophotography
Re: os.rename causes crash when dest. path > 31 characters
« Reply #11 on: 14 / July / 2021, 13:33:28 »
Thank you both of you. Ok, I will do further testings and try if it is possible to avoid a crash in my script as discussed in the mentioned topic.

My camera is a SX620HS. But I also got a slightly older SX710HS for testing. The older SX710HS hasn't crashed yet, but I am not sure if I ever had such a long path with it.

How can I check my DryOS version?
The SX710 is DryOS r57 and the SX620 is DryOS r58.

Re: os.rename causes crash when dest. path > 31 characters
« Reply #12 on: 14 / July / 2021, 13:59:34 »
Thank you for the information.

I just tested SX620HS and SX710HS and they both crash at >31 characters for the destination path. Considering the close versions the similar behaviour is no surprise.

*

Offline reyalp

  • ******
  • 14126
Re: os.rename causes crash when dest. path > 31 characters
« Reply #13 on: 14 / July / 2021, 14:01:35 »
os.rename doesn't seem to copy and delete. It seems to be a move. But if you use the chdk file browser then moving seems to be a copy and delete. Or for some other reason extreme slow.
As I mentioned in a previous thread, rename across directories is problematic on at least some cameras, including leading to filesystem corruption, so CHDK file browser does a copy and delete.

:) Sx620 & 710 have in trunc/...platform/.../stubs_entry.s
Code: [Select]
//#define CAM_DRYOS_2_3_R39 1 // Defined for cameras with DryOS version R39 or higher
//#define CAM_DRYOS_2_3_R47 1 // Defined for cameras with DryOS version R47 or higher

That means that both of my cameras are not in the DryOS 39-43 range, right?
No. Those defines apply to DryOS version greater than or equal to the named version. The actual dryos versions are listed in the stubs files.

(I for one often have trouble understanding caefix's posts. YMMV)

The SX710 is DryOS r57 and the SX620 is DryOS r58.
These versions should be able to handle much longer paths, but perhaps there are particular limits with rename. Keep in mind that that Canon firmware only uses 8.3 name in normal operation, and does not generally move / rename files at all.

IIRC, there has also been differences in behavior observed with files in the root of the SD card. I believe this was discussed in the LFN thread.

If you post a romlog from the crash, that might give some information about what's happening.

Quote
If A/b already exists then the content will be moved to A/a/b.
I definitely would not rely on rename (or any other file operations, for that matter) creating intervening directories.

I'd suggest you implement something like mkdir_m from https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/lua/rlibs.lua#ln497
Don't forget what the H stands for.

Re: os.rename causes crash when dest. path > 31 characters
« Reply #14 on: 14 / July / 2021, 14:33:57 »
@reyalp: I just ran your test script from the 31st of october 2015 on a SX710HS with the default limitations (<= 2000 for file name and path). It did not crash.

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: os.rename causes crash when dest. path > 31 characters
« Reply #15 on: 14 / July / 2021, 14:48:36 »
It did not crash.
:) Nor Sx620 crashed.
Code: [Select]
lfntest2.lua: 0.1-dev
RESULTS
path:   9 pass:  99 ( 108) fail:-
path:  20 pass:  33 (  53) fail:-
path:  48 pass:  33 (  81) fail:-
listdir name max=99 pass=99
listdir path max=108 pass=108
Edit:  :o I just tried to enter A/TESTFN with the file_browser... ...
Quote
Exception!! Vector 0x10
Task name: SpyTask
« Last Edit: 14 / July / 2021, 15:09:05 by Caefix »
All lifetime is a loan from eternity.

Re: os.rename causes crash when dest. path > 31 characters
« Reply #16 on: 14 / July / 2021, 15:09:46 »
@Caefix: Have you got a SX620HS, too? Thank you for testing because I have left mine at work.

@reyalp: I caused a crash. Restarted the camera and executed the romlog script. Logfile is in the attachment.

I share your view on clean programming and not using problematic functions which can cause a lot of trouble even if this happens just very few times.

The os.rename function was the only method I came up with to select a single directory to view the images inside. So it was the best method I had. If I could do better, then I would do so.

I use my camera very often at work to store images of how I need to build different things and how they were built in the past. The camera and the abilty to sort my images delivers quite some value to my daily earning money. So if you tell me not to do it because it can possibly corrupt the file system and maybe not even on my camera then this is a situation where I have to make a different decision: I choose the best possible way instead of no way.

You might had a chance to look at the script I wrote to do the renaming. It has a lot of error checks and does the task step for step with checking and possibly aborting instead of blindly continuing with the next step.

If there is anything we can do to fix the problem with os.rename, then I would appreciate it. Maybe it is possible somehow to write a fix.
« Last Edit: 14 / July / 2021, 15:23:17 by Joker135 »

*

Offline reyalp

  • ******
  • 14126
Re: os.rename causes crash when dest. path > 31 characters
« Reply #17 on: 14 / July / 2021, 15:59:53 »
So if you tell me not to do it because it can possibly corrupt the file system and maybe not even on my camera then this is a situation where I have to make a different decision: I choose the best possible way instead of no way.
I'm not telling you not to do it, I'm only reporting behavior that has been observed in related situations ;)

I mentioned filesystem corruption again to explain why the CHDK file browser uses copy and delete, not to say you shouldn't use rename if it works for you.

Quote
If there is anything we can do to fix the problem with os.rename, then I would appreciate it. Maybe it is possible somehow to write a fix.
As mentioned earlier, os.rename calls the underlying firmware rename() function. If the underling firmware doesn't have the capability you want, it's unlikely we add it, but it's always possible there are bugs in CHDK, or that understanding some additional details will show a way to accomplish what you want.

Does the problem still happen if intermediate directories exist?

Quote
@reyalp: I caused a crash. Restarted the camera and executed the romlog script. Logfile is in the attachment.
Did you use a script, or the CHDK menu? (Miscellaneous stuff->Debug Parameter->Save ROM Crash log)
Did the camera shut down after you tried to save the romlog?

The romlog is odd, from the last 3 lines of camera log output, it appears to show a crash while trying to save a romlog :blink:
Code: [Select]
00020940: SystemEventInit
00020940: System.Create
00020940: GetLogToFile

@Caefix please post the full romlog as an attachment.
Don't forget what the H stands for.

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: os.rename causes crash when dest. path > 31 characters
« Reply #18 on: 15 / July / 2021, 12:08:23 »
 ??? Vector Romlogs look like from this endless loop ...
Code: [Select]
  case TOKENIZER_EXCEPTION: // Romlog on demand? 20-60! secs later
ended=0; while (ended<1); {ended++;}
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14126
Re: os.rename causes crash when dest. path > 31 characters
« Reply #19 on: 15 / July / 2021, 13:08:39 »
??? Vector Romlogs look like from this endless loop ...
Code: [Select]
  case TOKENIZER_EXCEPTION: // Romlog on demand? 20-60! secs later
ended=0; while (ended<1); {ended++;}
I don't understand.
The quoted code is an infinite loop because of the ; after while.

It has nothing to do with the os.rename or the lfn test.

Vector 0x10 just means an invalid memory access, which could happen in many different ways.

Is the first romlog in your text file from the crash described in your post above (https://chdk.setepontos.com/index.php?topic=14399.msg146674#msg146674)

Have you modified the code for the build it was running?
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal