-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Reader's seek operation incorrectly panic when the parameter is not valid #2636
Comments
Yep! We should make sure all our internal logic hanlde those correctly. Would you like to go deep and try fix it? |
I am not familar with that but I would like to have a try |
I'm willing to provide help! You can debug in this way:
|
/// seek a negative position
pub async fn test_reader_seek_invalid(op: Operator) -> Result<()> {
let path = uuid::Uuid::new_v4().to_string();
debug!("Generate a random file: {}", &path);
let (content, size) = gen_bytes();
op.write(&path, content.clone())
.await
.expect("write must succeed");
let mut r = op.reader(&path).await?;
r.seek(std::io::SeekFrom::Current(-1024)).await?;
op.delete(&path).await.expect("delete must succeed");
Ok(())
} The log is 2023-07-14T06:37:19.152901Z DEBUG opendal::services: service=memory operation=read path=bfae56eb-ae99-4ca6-b000-4bdad69c85e1 range=0- -> got reader
at core/src/layers/logging.rs:273
2023-07-14T06:37:19.152933Z ERROR opendal::services: service=memory operation=Reader::seek path=bfae56eb-ae99-4ca6-b000-4bdad69c85e1 read=0 -> data read failed: Unexpected (permanent) at Reader::seek => invalid seek to a negative or overflowing position
Context:
service: memory
path: bfae56eb-ae99-4ca6-b000-4bdad69c85e1
at core/src/layers/logging.rs:1108
2023-07-14T06:37:19.153098Z DEBUG opendal::services: service=memory operation=read path=bfae56eb-ae99-4ca6-b000-4bdad69c85e1 read=0 -> data read finished
at core/src/layers/logging.rs:1035 |
Thanks for the find! We can add a new error code When we got an invalid input like Would you like to submit a PR for this change? |
By the way, it's not a panic. Maybe there are other problems (like in |
I have just one quesion. Why this Err cannot be catched by something like this https://gist.github.com/dqhl76/76cdb6364339ced8867db8eafdd7b7c2
|
Sure, I will do that. |
If the error is thrown due to panic, there is no way for us to catch it. That's why I advised #2636 (comment) If it's a normal error returned (like in this case), we can handle it. |
For the
seek
operation of OpenDAL'sreader
, if seek to a negative or overflowing position, it will cause panic unexpectedly.How to reproduce?
What we expected?
It will not cause panic and return the error in the
seek
's resultrelated discussion: https://discord.com/channels/1081052318650339399/1122785258501308497/1129261665146388490
The text was updated successfully, but these errors were encountered: