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

segfault #37

Closed
baslr opened this issue May 4, 2015 · 6 comments
Closed

segfault #37

baslr opened this issue May 4, 2015 · 6 comments

Comments

@baslr
Copy link

baslr commented May 4, 2015

gdb --args ./node test
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./node...done.
(gdb) run
Starting program: /root/pdf/node test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6795310 in PDFArray::GetLength() () from /root/pdf/node_modules/hummus/build/Release/hummus.node
(gdb) backtrace
#0  0x00007ffff6795310 in PDFArray::GetLength() () from /root/pdf/node_modules/hummus/build/Release/hummus.node
#1  0x00007ffff672cf16 in PDFArrayDriver::ToJSArray(v8::FunctionCallbackInfo<v8::Value> const&) () from /root/pdf/node_modules/hummus/build/Release/hummus.node
#2  0x00000000007a2d48 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) ()
#3  0x00000000007c3874 in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
#4  0x00002fc2e470740e in ?? ()
#5  0x00002fc2e4729102 in ?? ()
#6  0x00002fc2e4707361 in ?? ()
#7  0x00007fffffffe2e0 in ?? ()
#8  0x00007fffffffe360 in ?? ()
#9  0x00002fc2e47af711 in ?? ()
#10 0x0000165e4e03fd79 in ?? ()
#11 0x00002f4a3b1288f1 in ?? ()
#12 0x0000165e4e03fd79 in ?? ()
#13 0x000004456fb04121 in ?? ()
#14 0x000004456fb04121 in ?? ()
#15 0x000004456fb04121 in ?? ()
#16 0x000004456fb04121 in ?? ()
#17 0x0000000300000000 in ?? ()
#18 0x0000009400000000 in ?? ()
#19 0x0000165e4e058f81 in ?? ()
#20 0x00002f4a3b127d79 in ?? ()
#21 0x00007fffffffe3a8 in ?? ()
#22 0x00002fc2e47a46c9 in ?? ()
#23 0x00002f4a3b127031 in ?? ()
#24 0x0000165e4e058f81 in ?? ()
#25 0x00002f4a3b1269e1 in ?? ()
#26 0x00002f4a3b127031 in ?? ()
#27 0x00002f4a3b00e711 in ?? ()
#28 0x00002f4a3b00ceb9 in ?? ()
#29 0x00002f4a3b00cf01 in ?? ()
#30 0x00007fffffffe3d8 in ?? ()
#31 0x00002fc2e47a48b8 in ?? ()
#32 0x00002f4a3b00cf39 in ?? ()
#33 0x000004456fb561a9 in ?? ()
#34 0x00002f4a3b00cf51 in ?? ()
#35 0x00002f4a3b00cf01 in ?? ()
#36 0x00007fffffffe440 in ?? ()
#37 0x00002fc2e4759ec6 in ?? ()
#38 0x00002f4a3b00cf99 in ?? ()
#39 0x00002f4a3b00cfc1 in ?? ()
#40 0x00002f4a3b00cdb1 in ?? ()
#41 0x00002f4a3b00ce39 in ?? ()
#42 0x00002f4a3b00cf39 in ?? ()
#43 0x00002f4a3b00cf39 in ?? ()
#44 0x0000000500000000 in ?? ()
#45 0x0000000500000000 in ?? ()
#46 0x00002fc2e4759d21 in ?? ()
#47 0x0000000800000000 in ?? ()
#48 0x000004456fb635d1 in ?? ()
#49 0x00007fffffffe4b8 in ?? ()
#50 0x00002fc2e47a3966 in ?? ()
#51 0x00002f4a3b00cff1 in ?? ()
#52 0x00002f4a3b00cf39 in ?? ()
#53 0x00002f4a3b00cf51 in ?? ()
#54 0x000004456fb561f1 in ?? ()
#55 0x00002f4a3b00cff1 in ?? ()
#56 0x00002f4a3b00cf51 in ?? ()
#57 0x00002f4a3b00d011 in ?? ()
#58 0x000004456fb04121 in ?? ()
#59 0x000004456fb04121 in ?? ()
#60 0x00002f4a3b00cf99 in ?? ()
#61 0x00002f4a3b00ce39 in ?? ()
#62 0x0000165e4e01f729 in ?? ()
#63 0x00002f4a3b00ce81 in ?? ()
#64 0x00007fffffffe500 in ?? ()
#65 0x00002fc2e479de4c in ?? ()
#66 0x00002f4a3b00cfc1 in ?? ()
#67 0x00002f4a3b00d319 in ?? ()
#68 0x00002f4a3b00cdb1 in ?? ()
#69 0x0000165e4e01f729 in ?? ()
#70 0x00002f4a3b00d319 in ?? ()
#71 0x0000165e4e01f7c1 in ?? ()
#72 0x00002f4a3b004271 in ?? ()
#73 0x00007fffffffe548 in ?? ()
#74 0x00002fc2e479a600 in ?? ()
#75 0x00002f4a3b00cfc1 in ?? ()
#76 0x00002f4a3b00cdb1 in ?? ()
#77 0x00002f4a3b004239 in ?? ()
#78 0x0000165e4e01f7c1 in ?? ()
#79 0x00002f4a3b00d5e1 in ?? ()
#80 0x0000165e4e01f699 in ?? ()
#81 0x00002f4a3b004271 in ?? ()
#82 0x00007fffffffe5d0 in ?? ()
#83 0x00002fc2e478f6e5 in ?? ()
#84 0x00002f4a3b00cfc1 in ?? ()
#85 0x00002f4a3b00cdb1 in ?? ()
#86 0x0000165e4e01f699 in ?? ()
#87 0x00007fffffffe710 in ?? ()
#88 0x00002fc2e478f141 in ?? ()
#89 0x0000000000000002 in ?? ()
#90 0x00002f4a3b004271 in ?? ()
#91 0x00007fffffffe5d0 in ?? ()
#92 0x000004456fb04161 in ?? ()
#93 0x00002f4a3b00cdb1 in ?? ()
#94 0x000004456fb04121 in ?? ()
#95 0x000004456fb04121 in ?? ()
#96 0x00002f4a3b00cfc1 in ?? ()
#97 0x0000165e4e01f609 in ?? ()
#98 0x00002f4a3b004271 in ?? ()
#99 0x00007fffffffe618 in ?? ()
#100 0x00002fc2e478f0a4 in ?? ()
#101 0x000004456fb04161 in ?? ()
#102 0x000004456fb04101 in ?? ()
#103 0x00002f4a3b00d601 in ?? ()
#104 0x00002f4a3b0043c1 in ?? ()
#105 0x0000165e4e01f609 in ?? ()
#106 0x0000165e4e01f851 in ?? ()
#107 0x00002f4a3b004271 in ?? ()
#108 0x00007fffffffe688 in ?? ()
#109 0x00002fc2e476033f in ?? ()
#110 0x00002f4a3b0043c1 in ?? ()
#111 0x0000165e4e01f851 in ?? ()
#112 0x000004456fb04121 in ?? ()
#113 0x000004456fb04121 in ?? ()
#114 0x000004456fb04121 in ?? ()
#115 0x00002f4a3b0043c1 in ?? ()
#116 0x000004456fb04121 in ?? ()
#117 0x00002f4a3b00d629 in ?? ()
#118 0x000004456fb04121 in ?? ()
#119 0x00002f4a3b00d641 in ?? ()
#120 0x000004456fbb2351 in ?? ()
#121 0x00002f4a3b00d689 in ?? ()
#122 0x00007fffffffe6b8 in ?? ()
#123 0x00002fc2e475ed30 in ?? ()
#124 0x000004456fb56c01 in ?? ()
#125 0x000004456fbb2351 in ?? ()
#126 0x000004456fb63a61 in ?? ()
#127 0x000004456fb63aa9 in ?? ()
#128 0x00007fffffffe6f8 in ?? ()
#129 0x00002fc2e4756fe0 in ?? ()
#130 0x000004456fb63a01 in ?? ()
#131 0x000004456fb56c01 in ?? ()
#132 0x000004456fb63a61 in ?? ()
#133 0x00002fc2e4756f21 in ?? ()
#134 0x0000000800000000 in ?? ()
#135 0x0000000000000000 in ?? ()
(gdb) c
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
hummus = require 'hummus'

pdfWriter = hummus.createWriterToModify './test.pdf',{modifiedFilePath:'./test_modified.pdf'}

pageModifier = new hummus.PDFPageModifier pdfWriter,0

pageModifier.startContext().getContext() #.writeText 'Test Text',
pageModifier = new hummus.PDFPageModifier pdfWriter,0

pageModifier.startContext().getContext().writeText 'Test Text',
                           75,
                           10, {
                                font:pdfWriter.getFontForFile('./arial.ttf'),
                                size:50,
                                colorspace:'gray',
                                color:0x00}

pageModifier.endContext().writePage()

pdfWriter.end()

console.log 'done - ok'

Hummus v1.0.39, node v0.12.2 x86_64 (./configure --without-ssl2 --without-ssl3 --without-npm --gdb --debug)

@galkahana
Copy link
Owner

this part looks like a problem:

pageModifier = new hummus.PDFPageModifier pdfWriter,0

pageModifier.startContext().getContext() #.writeText 'Test Text',
pageModifier = new hummus.PDFPageModifier pdfWriter,0

try to remove the first 2 lines of this part.

@baslr
Copy link
Author

baslr commented May 5, 2015

Oh sorry, my fault. Copy paste mistake.
The executed js is:

// Generated by CoffeeScript 1.9.2
(function() {
  var hummus, pageModifier, pdfWriter;

  hummus = require('hummus');

  pdfWriter = hummus.createWriterToModify('./test.pdf', {
    modifiedFilePath: './test.pdf'
  });

  pageModifier = new hummus.PDFPageModifier(pdfWriter, 0);

  pageModifier.startContext().getContext().writeText('Test Text', 75, 10, {
    font: pdfWriter.getFontForFile('./arial.ttf'),
    size: 50,
    colorspace: 'gray',
    color: 0x00
  });

  pageModifier.endContext().writePage();

  pdfWriter.end();

  console.log('done - ok');

}).call(this);

I get:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6795310 in PDFArray::GetLength() () from /root/pdf/node_modules/hummus/build/Release/hummus.node
(gdb) backtrace
#0  0x00007ffff6795310 in PDFArray::GetLength() () from /root/pdf/node_modules/hummus/build/Release/hummus.node
#1  0x00007ffff672cf16 in PDFArrayDriver::ToJSArray(v8::FunctionCallbackInfo<v8::Value> const&) () from /root/pdf/node_modules/hummus/build/Release/hummus.node
#2  0x00000000007a2d48 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) ()
#3  0x00000000007c3874 in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()

The pdf was created with MS Word and Mac OS X 10.9.5 Quartz PDFContext

Found out that the segfault is not happening when I do PDFPageModifier(pdfWriter, 1) Write to 2nd page.

@galkahana
Copy link
Owner

Good. must be something unexpected data from with one of the fields. thanks. can you send me the test.pdf file? miminize possible mishaps in recreating the issue on my station.

b.t.w how did you get this beautiful stack trace?

@baslr
Copy link
Author

baslr commented May 5, 2015

It's gdb and I compiled node with --gdb

# what to start
gdb --args node test
# start node test
(gdb) run

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6795310 in PDFArray::GetLength() () from /root/pdf/node_modules/hummus/build/Release/hummus.node

# print stacktrace
(gdb) backtrace

I send you the pdf by email.

@galkahana
Copy link
Owner

oh alright.
got it. didn't expect annotations object to be an indirect array. pahhh.

checkin a solution, published to npm. should be fine now.

@baslr
Copy link
Author

baslr commented May 6, 2015

thx, with 1.0.40 the segfault is gone :)

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