Skip to content
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

Crash on multithreaded execution #42

Open
bademux opened this issue Jul 27, 2020 · 6 comments
Open

Crash on multithreaded execution #42

bademux opened this issue Jul 27, 2020 · 6 comments

Comments

@bademux
Copy link

bademux commented Jul 27, 2020

Lib crashed when execute on > 1 thread something like this

 executor.execute(() -> {
		try (FileChannel ch = FileChannel.open(path, READ);
			 VipsImage image = new VipsImage(ch.map(READ_ONLY, 0, ch.size()), (int) ch.size())) {
			image.resize(new Dimension(300, 300), true)
		}});
@dbouron
Copy link
Contributor

dbouron commented Jul 29, 2020

What is the format of the test image? Does is crash with a SIGSEGV?

@bademux
Copy link
Author

bademux commented Jul 29, 2020

Any jpeg (I have some pngs and gifs, but mostly jpegs)
It crashed as SIGSEGV.
Single thread is OK.
Tested on linux with 2 and 4 threads - hard crash.

@dbouron dbouron added the bug Something isn't working label Aug 5, 2020
@dbouron
Copy link
Contributor

dbouron commented Aug 5, 2020

I can reproduce using an ExecutorService with a CompletionService.
We aren't using byte buffers in production but byte arrays where we haven't any crash in MT context.
I will have a look when I have the time.

@dbouron
Copy link
Contributor

dbouron commented Aug 6, 2020

I suspect an early FileChannel closing in the try-with resources statement which unmaps the memory.
The JVM seems to crash after unmap.

In command line, it sometimes throws several CloseChannelException instead of sigsegv.
Moreover, I see several unmap() calls with stace before the crash.

@dbouron dbouron removed the bug Something isn't working label Aug 7, 2020
@bademux
Copy link
Author

bademux commented Aug 7, 2020

Hi, thanks for investigating the problem!
Maybe it is worth to change JVips API to prevent unmap problems?

@dbouron
Copy link
Contributor

dbouron commented Aug 10, 2020

I will have a look how to handle this case and what is possible to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants