Bug 53380

Summary: [Qt] WebKit does not build on Mac with WebKit 2
Product: WebKit Reporter: Benjamin Poulain <benjamin>
Component: WebKit2Assignee: Benjamin Poulain <benjamin>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eric, kimmo.t.kinnunen, laszlo.gombos, ossy, sam, s.mathur, webkit-ews, webkit.review.bot
Priority: P3 Keywords: Qt, QtTriaged
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Bug Depends on: 53377    
Bug Blocks: 50251    
Attachments:
Description Flags
Patch
none
Fix for Linux distros that don't support mkostemp (only mkstemp)
none
Fix for Linux
none
Patch
none
Patch
none
Patch none

Description Benjamin Poulain 2011-01-29 14:04:43 PST
WebKit does not build on Mac if WebKit 2 is enabled.
Comment 1 Benjamin Poulain 2011-01-29 14:17:17 PST
Created attachment 80572 [details]
Patch
Comment 2 Benjamin Poulain 2011-01-29 14:22:46 PST
I basically fixed the build issues one by one until it compiles, link and run :)

There is two things I am not sure, maybe Kimmo can tell:
-is "mkostemp(tempNameC, O_CREAT | O_CLOEXEC | O_RDWR))" subject to race condition on close-on-exec? Because the fallback use fcntl() after the creation, so there is some time without close-on-exec.
-is it ok to pass no flag to recvmsg()? The doc is unclear (it says one or more flags)
Comment 3 Eric Seidel (no email) 2011-01-30 03:44:16 PST
Sam may like to see wk2 changes go by, even though he doesn't work with qt.
Comment 4 Kimmo Kinnunen 2011-01-30 22:27:29 PST
(In reply to comment #2)
> I basically fixed the build issues one by one until it compiles, link and run :)

Nice!
 
> There is two things I am not sure, maybe Kimmo can tell:
> -is "mkostemp(tempNameC, O_CREAT | O_CLOEXEC | O_RDWR))" subject to race condition on close-on-exec? Because the fallback use fcntl() after the creation, so there is some time without close-on-exec.

The race is about other thread forking the process after mkostemp but before the fctnl. In this case it is not a problem, and mkstemp + fcntl suffices. If you want to refine the patch, IMHO it could be used as the only codepath in order to reduce the #ifdef'ing.

> -is it ok to pass no flag to recvmsg()? The doc is unclear (it says one or more flags)

I interpret the man page ambiguous on flag. As far as I tested, passing 0 is good.
Comment 5 Siddharth Mathur 2011-02-03 15:55:40 PST
(In reply to comment #4)
> (In reply to comment #2)
> > I basically fixed the build issues one by one until it compiles, link and run :)
> 
> Nice!
> 
> > There is two things I am not sure, maybe Kimmo can tell:
> > -is "mkostemp(tempNameC, O_CREAT | O_CLOEXEC | O_RDWR))" subject to race condition on close-on-exec? Because the fallback use fcntl() after the creation, so there is some time without close-on-exec.
> 
> The race is about other thread forking the process after mkostemp but before the fctnl. In this case it is not a problem, and mkstemp + fcntl suffices. If you want to refine the patch, IMHO it could be used as the only codepath in order to reduce the #ifdef'ing.
> 
> > -is it ok to pass no flag to recvmsg()? The doc is unclear (it says one or more flags)
> 
> I interpret the man page ambiguous on flag. As far as I tested, passing 0 is good.

Since I see that kling has r- the patch, Kimmo, would you be kind enough to upload a patch that fixes this issue for Mac and/or Linux distros that don't support 'mkostemp' and the new flags? 

../../../Source/WebKit2/Platform/qt/SharedMemoryQt.cpp: In static member function 'static WTF::PassRefPtr<WebKit::SharedMemory> WebKit::SharedMemory::create(size_t)':
../../../Source/WebKit2/Platform/qt/SharedMemoryQt.cpp:109: error: 'O_CLOEXEC' was not declared in this scope
../../../Source/WebKit2/Platform/qt/SharedMemoryQt.cpp:109: error: 'mkostemp' was not declared in this scope
../../../Source/WebKit2/Platform/qt/SharedMemoryQt.cpp: In member function 'bool WebKit::SharedMemory::createHandle(WebKit::SharedMemory::Handle&, WebKit::SharedMemory::Protection)':
../../../Source/WebKit2/Platform/qt/SharedMemoryQt.cpp:199: error: 'O_CLOEXEC' was not declared in this scope
make[1]: *** [obj/release/SharedMemoryQt.o] Error 1
make[1]: *** Waiting for unfinished jobs....
../../../Source/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp: In member function 'void CoreIPC::Connection::readyReadHandler()':
../../../Source/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp:168: error: 'MSG_CMSG_CLOEXEC' was not declared in this scope
make[1]: *** [obj/release/ConnectionQt.o] Error 1
Comment 6 Kimmo Kinnunen 2011-02-04 02:33:26 PST
(In reply to comment #5)
> Since I see that kling has r- the patch, Kimmo, would you be kind enough to upload a patch that fixes this issue for Mac and/or Linux distros that don't support 'mkostemp' and the new flags? 

(12:32:13 PM) kling: kimmok: benjaminp said he wanted to make a new version based on your comments, and told me to r- the old one
Comment 7 Siddharth Mathur 2011-02-04 14:47:07 PST
Created attachment 81289 [details]
Fix for Linux distros that don't support mkostemp (only mkstemp)
Comment 8 Siddharth Mathur 2011-02-04 15:21:24 PST
Created attachment 81303 [details]
Fix for Linux 

(It will be good if someone can test this too)
Comment 9 Benjamin Poulain 2011-02-04 16:37:24 PST
Comment on attachment 81303 [details]
Fix for Linux 

And what? If the system is not POSIX.1-2008 you just ignore close on exec?

Seem bogus to me. I said I would update for something more generic, not just ignore the stuff I don't like.
Comment 10 Early Warning System Bot 2011-02-04 16:52:47 PST
Attachment 81303 [details] did not build on qt:
Build output: http://queues.webkit.org/results/7699336
Comment 11 Kimmo Kinnunen 2011-02-05 00:06:42 PST
(In reply to comment #7)
> Created an attachment (id=81289) [details]
> Fix for Linux distros that don't support mkostemp (only mkstemp)

Siddharth, was there something that didn't work for you in Benjamin's original patch?

Benjamin, Andreas:
Since this is fairly important, could we get the Benjamin's original patch in to get things compiling again? With cq+ perhaps, so mac compiles wouldn't block? And then decreasing the #ifdef'ing would come as second priority..
Comment 12 Andreas Kling 2011-02-05 07:25:55 PST
Comment on attachment 80572 [details]
Patch

@Kimmo: Sure, let's land this for now.
Comment 13 Benjamin Poulain 2011-02-05 07:29:09 PST
Comment on attachment 80572 [details]
Patch

Patch on the way
Comment 14 Benjamin Poulain 2011-02-05 08:05:15 PST
Created attachment 81363 [details]
Patch
Comment 15 Andreas Kling 2011-02-05 10:13:32 PST
Comment on attachment 81363 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=81363&action=review

r=me

> Source/WebKit2/Platform/qt/SharedMemoryQt.cpp:206
> +    while ((fcntl(duplicatedHandle, F_SETFD,  FD_CLOEXEC | accessModeFile(protection)) == -1)) {

Extra space before FD_CLOEXEC.

> Source/WebKit2/UIProcess/WebPageProxy.cpp:1093
> +#if defined(__APPLE__) && !PLATFORM(QT)

This is quite ugly. I wish we'd use something other than __APPLE__ for mac-port-specific stuff.
Comment 16 Benjamin Poulain 2011-02-05 11:58:21 PST
Created attachment 81368 [details]
Patch
Comment 17 Early Warning System Bot 2011-02-05 12:11:29 PST
Attachment 81368 [details] did not build on qt:
Build output: http://queues.webkit.org/results/7701411
Comment 18 Benjamin Poulain 2011-02-05 12:46:15 PST
Created attachment 81371 [details]
Patch

oops
Comment 19 WebKit Review Bot 2011-02-05 13:03:10 PST
Attachment 81368 [details] did not build on mac:
Build output: http://queues.webkit.org/results/7697938
Comment 20 WebKit Commit Bot 2011-02-06 05:24:05 PST
Comment on attachment 81371 [details]
Patch

Clearing flags on attachment: 81371

Committed r77765: <http://trac.webkit.org/changeset/77765>
Comment 21 WebKit Commit Bot 2011-02-06 05:24:11 PST
All reviewed patches have been landed.  Closing bug.
Comment 22 Siddharth Mathur 2011-02-07 06:43:52 PST
Thank you Benjamin and Kling!