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

fix hang in test/26fork.t on Win32 #32

Closed
wants to merge 2 commits into from
Closed

Conversation

bulk88
Copy link
Contributor

@bulk88 bulk88 commented Dec 10, 2014

See #31 for bug description.

The test now passes (doesn't hang).

C:\sources\inline-c-pm>perl -Ilib -Itest test/26fork.t
The process cannot access the file because it is being used by another process.
ok 1 - child exited status 0
ok 2 - bind was successful
ok 3 - bound func no die()
ok 4 - bound func gave right result
1..4

C:\sources\inline-c-pm>perl -Ilib -Itest test/26fork.t
The process cannot access the file because it is being used by another process.
ok 1 - child exited status 0
ok 2 - bind was successful
ok 3 - bound func no die()
ok 4 - bound func gave right result
1..4

C:\sources\inline-c-pm>perl -Ilib -Itest test/26fork.t
The process cannot access the file because it is being used by another process.
ok 1 - child exited status 0
not ok 2 - bind was successful
#   Failed test 'bind was successful'
#   at test/26fork.t line 20.
#          got: '
# A problem was encountered while attempting to compile and install your Inline
# C code. The command that failed was:
#   "c:\perl521\bin\perl.exe Makefile.PL > out.Makefile_PL 2>&1" with error code
 1
#
# The build directory was:
# C:\sources\inline-c-pm\_Inline_26fork.6120\build\_26fork_t_0cc7
#
# To debug the problem, cd to the build directory, and inspect the output files.

#
#  at test/26fork.t line 14.
#       ...propagated at lib/Inline/C.pm line 842.
# '
#     expected: ''
not ok 3 - bound func no die()
#   Failed test 'bound func no die()'
#   at test/26fork.t line 22.
#          got: 'Undefined subroutine &main::add called at test/26fork.t line 21
.
# '
#     expected: ''
not ok 4 - bound func gave right result
#   Failed test 'bound func gave right result'
#   at test/26fork.t line 23.
#          got: undef
#     expected: '10'
1..4
# Looks like you failed 3 tests of 4.
cannot unlink file for C:\sources\inline-c-pm\_Inline_26fork.6120\lib\auto\_26fo
rk_t_0cc7\_26fork_t_0cc7.dll: Permission denied at test/TestInlineSetup.pm line
53.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.6120\lib\auto\
_26fork_t_0cc7: Directory not empty at test/TestInlineSetup.pm line 53.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.6120\lib\auto:
 Directory not empty at test/TestInlineSetup.pm line 53.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.6120\lib: Dire
ctory not empty at test/TestInlineSetup.pm line 53.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.6120: Director
y not empty at test/TestInlineSetup.pm line 53.

C:\sources\inline-c-pm>

remaining problem is either to sleep more until the dll is unloaded or use forceunlink() from ExtUtils::Install which renames the dlll.

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 10, 2014

Updated the commit, the first one had a race condition and I saw the lock was ignored (my mistake) after I tested the locking ability with warn statements.

C:\sources\inline-c-pm>prove -lv test/26fork.t
test/26fork.t ..
ok 1 - child exited status 0
ok 2 - bind was successful
ok 3 - bound func no die()
ok 4 - bound func gave right result
1..4
cannot unlink file for C:\sources\inline-c-pm\_Inline_26fork.7304\lib\auto\_26fork_t_0cc7\_26fork_t_0cc7.dll.AAA: Permission denied at test/TestInlineSetup.pm line 58.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.7304\lib\auto\_26fork_t_0cc7: Directory not empty at test/TestInlineSetup.pm line 58.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.7304\lib\auto: Directory not empty at test/TestInlineSetup.pm line 58.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.7304\lib: Directory not empty at test/TestInlineSetup.pm line 58.
cannot remove directory for C:\sources\inline-c-pm\_Inline_26fork.7304: Directory not empty at test/TestInlineSetup.pm line 58.
ok
All tests successful.
Files=1, Tests=4, 20 wallclock secs ( 0.16 usr +  0.00 sys =  0.16 CPU)
Result: PASS

C:\sources\inline-c-pm>

The C:\sources\inline-c-pm\_Inline_26fork.7304\lib\auto\_26fo rk_t_0cc7\_26fork_t_0cc7.dll.AAA DLL is still in memory in the process according to vmmap, DynaLoader::dl_unload_file or the END{} in TestInlineSetup is doing something wrong or something.

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 10, 2014

Repushed. Fixed "cannot unlink file for C:\sources\inline-c-pm_Inline_26fork.7304\lib\auto_26fo
rk_t_0cc7_26fork_t_0cc7.dll.AAA: Permission denied at test/TestInlineSetup.pm line 58."

C:\sources\inline-c-pm>perl -Ilib -Itest test/26fork.t
ok 1 - child exited status 0
ok 2 - bind was successful
ok 3 - bound func no die()
ok 4 - bound func gave right result
1..4

C:\sources\inline-c-pm>

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 10, 2014

Repushed, included the stuff from 1739b57 which was a patch to an older removed commit.

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 10, 2014

It also seems I fixed #19 in this patch without knowing about #19 .

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 10, 2014

Repushed, changed sterilization of the mutex name per MSDN docs (no thanks to Win32::IPCs docs which havent been updated in more than a decade). The starting the name with "C:" always failed. Adding 'Inline__C_' made it not fail, most of the time atleast, except in 27inline_maker.t where it too failed. So removing all the fwd slashes fixed 27inline_maker.t and it passes for me now (I had to uncomment the win32 skip all).

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 19, 2014

Any updates?

@ingydotnet
Copy link
Owner

@bulk88 I'm waiting for someone to figure out why t/27 fails.

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 19, 2014

This commit doesn't touch file 27inline_maker.t . 27inline_maker.t working on Win32 was just a fun fact I discovered. I reverted to CPAN 0.67 without the patch in this PR, tested 27inline_maker.t and it passed. So this patch is not needed for 27inline_marker.t to pass. I'm not sure where 19ae41b came from PR/Issue ticket wise so IDK why it was marked failing. When you figure out why 27inline_maker.t doesn't work on non-Win32 you can uncomment the Win32 OS too at that time. Or uncomment 27.t on Win32 only today, independent of this PR. I'd like to see this PR done with soon so I can delete my repo.

@sisyphus
Copy link
Collaborator

sisyphus commented Dec 19, 2014

Or uncomment 27.t on Win32 only today, independent of this PR.

On I-C-0.64 27.t fails for me on Windows7 quite drastically and in a bizarre
way.
Things are much improved with I-C-0.67 (EU-MM-7.04) and it seems to be
failing test 7 only:

t/27inline_maker.t ....... 6/?
# Failed test 'make install'
# at t/27inline_maker.t line 53.
# Can't open file C:\sisyphusion\Inline-C-0.67_Inline_27inline_maker.740\instdir\lib\perl5\MSWin32-x86-multi-thread\auto\Math\Simple.packlist: Permission denied at C:/MinGW/perl516/lib/ExtUtils/Install.pm line 855.
# Files found in blib\arch: installing files in blib\lib into architecture dependent library tree
# Installing C:\sisyphusion\Inline-C-0.67_Inline_27inline_maker.740\instdir\lib\perl5\MSWin32-x86-multi-thread\auto\Math\Simple.packlist
# Installing C:\sisyphusion\Inline-C-0.67_Inline_27inline_maker.740\instdir\lib\perl5\MSWin32-x86-multi-thread\auto\Math\Simple\Simple.dll
# Installing C:\sisyphusion\Inline-C-0.67_Inline_27inline_maker.740\instdir\lib\perl5\MSWin32-x86-multi-thread\Math\Simple.pm
# dmake:  Error code 141, while making 'pure_site_install'
t/27inline_maker.t ....... 8/? # Looks like you failed 1 test of 8.

Cheers,
Rob

@mohawk2
Copy link
Collaborator

mohawk2 commented Dec 24, 2014

@bulk88, Win32::Mutex is a CPAN module and I'd like to avoid dependencies. Can you please redo this using eg flock()?

@mohawk2
Copy link
Collaborator

mohawk2 commented Dec 24, 2014

From IRC #win32:

[10:01] <@bulk88> mohawk you cant use flock and psuedofor/ or an ithread on win32 perl, on NT < 6
[10:02] <@bulk88> Win32::Mutex is the properway to sycronisize things
[10:03] <mohawk> we'll need a dynamic dep facility for I::C, and zild isn't super-flexible

Dynamic dep facility is because obviously we don't (need/want to declare) a dependency on Win32::Mutex except on Win32.

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 24, 2014

26t became stable because I used Win32's native Kernel provided synchronization APIS. Not a hacked up API of using flock for syncronixation,. Using native Win32 IPC is going to be better than try hacked up attempts that dont even reach the claims they show off.

@bulk88
Copy link
Contributor Author

bulk88 commented Dec 25, 2014

ATM I am refactoring Win32::IPC (Win32::Mutex is distributed in Win32::IPC). Should I make Win32::Mutex build and install (but not provide any subs on Unix for obvious reasons) on Unix and release it to CPAN?

@ingydotnet
Copy link
Owner

Fixed

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

Successfully merging this pull request may close these issues.

None yet

4 participants