neraliu / tainted-phantomjs

Tainted PhantomJS
BSD 3-Clause "New" or "Revised" License
53 stars 12 forks source link

Build failure on x64 #3

Closed andresriancho closed 10 years ago

andresriancho commented 10 years ago

I'm on linux ubuntu 12.04 LTS, follow the instructions in http://phantomjs.org/build.html to install the build dependencies after a couple of minutes of building I get:

config.o: In function `Config::loadJsonFile(QString const&)':
config.cpp:(.text+0x57b): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
phantom.o: In function `Phantom::loadModule(QString const&, QString const&)':
phantom.cpp:(.text+0x2912): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
phantom.o: In function `Phantom::onInitialized()':
phantom.cpp:(.text+0x34fa): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
webpage.o: In function `WebPage::evaluateJavaScript(QString const&)':
webpage.cpp:(.text+0x2ab2): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
webpage.o: In function `WebPage::windowName() const':
webpage.cpp:(.text+0x3c9b): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
webpage.o:webpage.cpp:(.text+0x3d80): more undefined references to `QWebFrame::evaluateJavaScript(QString const&, QString const&)' follow
webpage.o: In function `WebPage::renderPdf(QString const&)':
webpage.cpp:(.text+0xa4d7): undefined reference to `QWebFrame::print(QPrinter*, QWebFrame::PrintCallback*) const'
webpage.o: In function `getHeaderFooter(QMap<QString, QVariant> const&, QString const&, QWebFrame*, int, int)':
webpage.cpp:(.text+0xcd3b): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
csconverter.o: In function `CSConverter::CSConverter()':
csconverter.cpp:(.text+0x91): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
csconverter.o: In function `CSConverter::convert(QString const&)':
csconverter.cpp:(.text+0x2d2): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
utils.o: In function `Utils::injectJsInFrame(QString const&, QString const&, Encoding const&, QString const&, QWebFrame*, bool)':
utils.cpp:(.text+0x119f): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
utils.o: In function `Utils::loadJSForDebug(QString const&, QString const&, Encoding const&, QString const&, QWebFrame*, bool)':
utils.cpp:(.text+0x14ff): undefined reference to `QWebFrame::evaluateJavaScript(QString const&, QString const&)'
repl.o:repl.cpp:(.text+0x33c): more undefined references to `QWebFrame::evaluateJavaScript(QString const&, QString const&)' follow
collect2: ld returned 1 exit status
make[1]: *** [../bin/phantomjs] Error 1
make[1]: Leaving directory `/home/pablo/PycharmProjects/tpjs/src'
make: *** [sub-src-phantomjs-pro-make_default-ordered] Error 2

Any ideas on what's wrong?

yukinying commented 10 years ago

Just to quickly verify...

  1. does the build step compile src/qt/lib/libQtWebKit.a ?
  2. if so, what's the output of
nm -C src/qt/lib/libQtWebKit.a | grep QWebFrame::evaluateJavaScript

for your reference, I got this is RHEL:

0000000000000000 T QWebFrame::evaluateJavaScript(QString const&, QString const&)
andresriancho commented 10 years ago

does the build step compile src/qt/lib/libQtWebKit.a ?

No, find . -name libQtWebKit.a returns nothing.

yukinying commented 10 years ago

@neraliu Issue is reproducible in this travis job: https://travis-ci.org/yukinying/tpjs/builds/22235114

andresriancho commented 10 years ago

Tried to change the QMAKE_LFLAGS, as explained here https://github.com/ariya/phantomjs/issues/10635 and failed too:

--- a/src/qt/src/3rdparty/webkit/Source/common.pri
+++ b/src/qt/src/3rdparty/webkit/Source/common.pri
@@ -6,7 +6,7 @@ contains(JAVASCRIPTCORE_JIT,no): DEFINES+=ENABLE_JIT=0
 linux-g++ {
 isEmpty($$(SBOX_DPKG_INST_ARCH)):exists(/usr/bin/ld.gold) {
     message(Using gold linker)
-    QMAKE_LFLAGS+=-fuse-ld=gold
+    #QMAKE_LFLAGS+=-fuse-ld=gold
 }
 }
yukinying commented 10 years ago

Cause of it:

../../JavaScriptCore/runtime/JSGlobalData.cpp:148:5: error: size of array 
  ‘dummysizeof_JSString_must_be_less_than_storage’ is negative

Seems it is compiling the 64 bit library and JSString size is larger than the asserted value. @neraliu , do we have the compiling instruction for 32 bit binary over a 64 bit environment?

Btw, we are working on moving our logic away from tamping the JSGlobalData. (See #4)

andresriancho commented 10 years ago

All right, so when #4 is fixed, it should build on 64bit?

yukinying commented 10 years ago

Yes, absolutely.

neraliu commented 10 years ago

just give u the quick solution first, we will move back the configuration in qmake later.

quick solution

  1. open the file src/qt/src/3rdparty/webkit/Source/JavaScriptCore/config.h 2.1. make sure JSC_TAINTED_32 is defined 2.2. make sure JSC_TAINTED_64 is undefined
  2. do the same in src/qt/src/3rdparty/webkit/Source/WebCore/config.h
andresriancho commented 10 years ago

Both files looked the same:

#define JSC_TAINTED_32          1
// #define JSC_TAINTED_64          1

Which match what you say "make sure JSC_TAINTED_32 is defined". Since I didn't change any files, I suspect you intended me to do the opposite. Changed to:

//#define JSC_TAINTED_32          1
#define JSC_TAINTED_64          1

Run ./build.sh and now it works!

rodrigo@foobar:~/tpjs$ ./bin/phantomjs 
phantomjs> 

My box is Linux foobar 3.2.0-60-generic #91-Ubuntu SMP Wed Feb 19 03:54:44 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

dmitris commented 10 years ago

Experience similar to that of Andres - was able to compile after changing 32 to 64 in several #defines:

diff --git a/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/config.h b/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/config.h
index 6a53b39..067b394 100644
--- a/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/config.h
+++ b/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/config.h
@@ -134,14 +134,14 @@

 #if !defined(JSC_TAINTED)
 #define JSC_TAINTED             1
-#define JSC_TAINTED_32          1
+#define JSC_TAINTED_64          1
 // #define JSC_TAINTED_64          1
 // if I use 16 bits for storing the tainted number, i can identify 2^16 sources. it is enough for most of the use case.
 /*
 | 8 bits | 8 bits | 8 bits | 8 bits |
 - the last 16 bits is used for carrying the tainted number for identifying how the sources and sinks.
 */
-#define JSC_TAINTED_BIT        32
+#define JSC_TAINTED_BIT        64
 #define JSC_TAINTED_MAX        0xffff
 // the debug flag of the hack
 // #define JSC_TAINTED_DEBUG   1
diff --git a/src/qt/src/3rdparty/webkit/Source/WebCore/config.h b/src/qt/src/3rdparty/webkit/Source/WebCore/config.h
index ed0a951..ff8adfc 100644
--- a/src/qt/src/3rdparty/webkit/Source/WebCore/config.h
+++ b/src/qt/src/3rdparty/webkit/Source/WebCore/config.h
@@ -263,14 +263,14 @@ typedef float CGFloat;

 #if !defined(JSC_TAINTED)
 #define JSC_TAINTED             1
-#define    JSC_TAINTED_32      1
+#define    JSC_TAINTED_64      1
 // #define JSC_TAINTED_64      1
 // if I use 16 bits for storing the tainted number, i can identify 2^16 sources. it is enough for most of the use case.
 /*
 | 8 bits | 8 bits | 8 bits | 8 bits |
 - the last 16 bits is used for carrying the tainted number for identifying how the sources and sinks.
 */
-#define JSC_TAINTED_BIT         32
+#define JSC_TAINTED_BIT         64 
 #define JSC_TAINTED_MAX         0xffff
 // the debug flag of the hack
 #define JSC_TAINTED_DEBUG      1
neraliu commented 10 years ago

can u try this branch and see on 64 bit platform? https://github.com/neraliu/tpjs/tree/rhel64-64-devel

andresriancho commented 10 years ago

You guys should configure travis so that all your branches, including this one for 64bit experiments, are built. I don't see any builds for it here: https://travis-ci.org/yukinying/tpjs

andresriancho commented 10 years ago

With the latest changes in the rhel64-64-devel branch, it is building properly. Leaving this one open so you guys remember to:

neraliu commented 10 years ago

yes. i will do it next

neraliu commented 10 years ago

i am closing this issue as it is done, and have created the issue #13 and #14 to follow up