daeken / daeken/PepakuraReverse
struct.error: unpack requires a string argument of length 8
- Dominant language
- Python
- Stars
- 40
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I'm trying to use your scripts, but I'm having trouble running the loader on some .PDOs and I hope you can help me. On some files, I get "struct.error: unpack requires a string argument of length 8" at random times on execution.
For example, running the loader on one of the example files you give, P349.pdo, I get the next error:
```
Traceback (most recent call last):
File "loader.py", line 229, in
parse(data)
File "loader.py", line 101, in parse
print 'unk6:', arr(buf.double, buf.double, buf.double, buf.double)
File "loader.py", line 57, in double
return self.unpack('d')
File "loader.py", line 27, in unpack
ret = struct.unpack(fmt, self.read(struct.calcsize(fmt)))
struct.error: unpack requires a string argument of length 8
```
I looked around a bit and figured that at that point it runs something like:
`struct.unpack(d, self.data[87:95])`
And `len(self.data[87:95])` should be 8, but printing `len(buf.data[87:95])` on the console gives 5, and that doesn't make sense. It happens to other files, at diferent points (for example, while parsing the vertices), and on some files it doesn't happen at all.
I don't know what am I doing wrong, can you help me?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the failure with P349.pdo and trace loader.py through parse, arr, double, and unpack. Inspect why the data slice at the failing offset is shorter than struct.calcsize(fmt); done means identifying the input or parsing condition that causes the short read and handling it consistently for affected PDO files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- reverse-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100