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] ASAN heap-use-after-free while concurrently opening PSD files #3824
Comments
The following snippet is sufficient for me to repro a variety of oddness stemming from that
|
I have some PSD overhaul in progress, see #3807 Before I dig into the current issue, would you please see if you are able to pull that patch and determine if the thread issue is still a problem with those proposed changes? |
Sadly, yes, the issue is there after applying your change. I had to switch back to Windows for compiling but it's also firing ASAN hits in the code path (different than before fwiw).
|
Ok, thanks, I will dig into this. |
We may have users running into this now so I've taken another look. Unfortunately I haven't quite root caused it but it does seem related to the ImageCache. If I change While I suspect this name collision to be logically incorrect, and it should probably be changed, that still leaves the question of why such a collision yields crashes. |
Oh, I see, yes. If the ImageBufs are underneath using the ImageCache as an intermediary (including for storing the spec and metadata), we are violating a basic IC assumption that reading one named image twice should yield the same results! I'm not sure that the ImageCache per se is not thread safe, but the way we are using it in this spot seems very unwise -- we are inherently setting up several reads simultaneously using the same filename but that certainly represent different images (possibly having different dimensions, I bet that's what really hurts). I think that the best solution is just to give that ImageBuf a unique name so they can't conflict. That's simple, I will do that right now and submit a PR. In the longer run, I've been thinking for quite a while that the rules for when an IB uses IC as backing, or not, is complicated and hard to reason about, and I have been contemplating a refactor where IB by default does not use IC underneath, unless the IB is constructed (or reset) with a pointer to an IC to use. That is, leave it totally to the caller to determine if they want an IC-backed IB, and for those that are not IC-back, really really be not IC-backed and have no hidden implicit use of IC. But let's tackle that as a separate, later step. |
Proposed fix here: #3877 |
When reading a PSD file, if it contains a thumbnail, we read it from the in-memory blob with a combination of an IOMemReader and an ImageBuf. But... we always named it "thumbnail.jpg" without considering that multiple simultaneous PSD files reading identically named images (but which are in fact different) could cause a weird kind of clashing in any underlying use of ImageCache! The simple fix is to use ordinary ImageInput approach to reading the thumbnail from the IOMemReader, but just store it in the ImageBuf. Fixes #3824 Signed-off-by: Larry Gritz <lg@larrygritz.com>
…demySoftwareFoundation#3877) When reading a PSD file, if it contains a thumbnail, we read it from the in-memory blob with a combination of an IOMemReader and an ImageBuf. But... we always named it "thumbnail.jpg" without considering that multiple simultaneous PSD files reading identically named images (but which are in fact different) could cause a weird kind of clashing in any underlying use of ImageCache! The simple fix is to use ordinary ImageInput approach to reading the thumbnail from the IOMemReader, but just store it in the ImageBuf. Fixes AcademySoftwareFoundation#3824 Signed-off-by: Larry Gritz <lg@larrygritz.com>
Describe the bug
See below for the full ASAN output but it seems like the ImageCache might not be threadsafe in this particular instance maybe?
To Reproduce
Steps to reproduce the behavior:
oiio-images
repoPSDInput::load_resource_thumbnail
code path (relating to theImageCache
and copying ofImageSpec
s)Expected behavior
No crash
Evidence
oiio-asan.txt
If I disable threading within the application, so it only loads 1 .PSD at a time, things seem ok.
I haven't been able to nail down the cause. Any ideas? I can attempt a stand alone repro sometime tomorrow maybe and will try to help out as best I can.
Platform information:
The text was updated successfully, but these errors were encountered: