In addition here's the offending line of emscripten code (it should be 
retrieving the pointer to the _cairo_filler_line_to function or "852"):

 i38 = FUNCTION_TABLE_iiii[(SAFE_HEAP_LOAD(i3 | 0, 4, 0, 0) | 0) & 
511](SAFE_HEAP_LOAD(i3 + 4 | 0, 4, 0, 0) | 0 | 0, i1, i5) | 0;

This returns back a pointer to the UndoManager in webkit, not the cairo 
function assigned. 

On Friday, May 30, 2014 6:03:20 PM UTC-6, Trevor Linton wrote:
>
> Hi Alon,
>
> I'm having difficulties translating the emscripten generated code back 
> into a potential C/C++ issue.  It seems the offending line is when a 
> structure has a pointer to a function assigned to it.  The structure is 
> then passed into a variety of other functions (unmodified) and later called 
> with the offending stack trace.
>
>
> This call:
>
> _cairo_spline_init (&spline, 
> (cairo_spline_add_point_func_t)_cairo_filler_line_to, filler, 
> &filler->current_point, p1, p2, p3)
> seems suspicious in emscripten code, as its translate as:
>
> if ((__cairo_spline_init(i6, 852, i1, i7, i2, i3, i4) | 0) == 0) {
>
> The value of i6, i'd assume holds the reference to spline, 852 seems as if 
> it would be some sort of pointer to the function "_cairo_filler_line_to" 
> ? 
>
> If this looks correct I can keep tracing around to see how this got so out 
> of whack, its very possible its simply a C/C++ issue I just wanted to make 
> sure this isn't an obvious emscripten problem as its been rare to see raw 
> numbers being passed through functions when i'm tracing emscripten 
> generated code.
>
>
>
>
> On Thursday, May 29, 2014 11:40:12 AM UTC-6, Alon Zakai wrote:
>
> I would build and run with -s SAFE_HEAP=1 (and I see you have assertions 
> on already), as mentioned on 
> https://github.com/kripken/emscripten/wiki/Debugging . Hopefully that 
> will report a warning or error about function pointer use that can help.
>
> - Alon
>
>
>
> On Wed, May 28, 2014 at 4:30 PM, Trevor Linton <[email protected]> 
> wrote:
>
> Hi All,
>
> I'm having an issue mixing C++ and C code together.  Functions are 
> assigned to a structure in a C library, but when the C library executes 
> (and thus the function pointed to on the structure) it ends up randomly 
> executing a C++ member of a class.  
>
> The C library is cairo, and the calling library is a WebKit.  I'm curious 
> if anyone can provide some direction on how to resolve this? Additional 
> information below is provided.
>
>
>
> *Linking to JS step:*
>
> /Users/tlinton/Library/Emscripten/emscripten/1.16.0/emcc  -s 
> EXPORTED_FUNCTIONS="['_main','_scalefactor','_createWebKit','_setHtml','_setTransparent','_scrollBy','_resize']"
>  
> --embed-files ../src/assets/fontconfig/fonts@/usr/share/fonts --embed-files 
> ../src/assets/fontconfig/config/fonts.conf@/etc/fonts/fonts.conf 
> --embed-files 
> ../src/assets/fontconfig/cache@/usr/local/var/cache/fontconfig -s 
> TOTAL_MEMORY=50331648 -s FULL_ES2=1  -o webkit.html -s ASSERTIONS=2 -O2 -g2 
> --js-opts 0 -s ALIASING_FUNCTION_POINTERS=0 obj/src/webkit.WebView.o 
> obj/src/webkit.Main.o libxml.bc libjpeg_turbo.bc libpng.bc libfreetype.bc 
> libharfbuzz.bc libcairo.bc libcurl.bc libzlib.bc libpixman.bc 
> libfontconfig.bc libwebcore_xml.bc libwebcore_wtf.bc libwebcore_svg.bc 
> libwebcore_loader.bc libwebcore_html.bc libwebcore_dom.bc libwebcore_css.bc 
> libwebcore_rendering.bc libwebcore_page.bc libwebcore_style.bc 
> libwebcore_derived.bc libwebcore_platform.bc libwebcore_history.bc 
> libwebcore_editing.bc libwebcore_angle.bc libwebcore_support.b
>
> *No warnings are produced when compiled, i'm using emscripten 1.16.0. *
>
>
> *Here's the stack trace:*
>
>
>    1. _WTFReportAssertionFailurewebkit.js:593173
>    2. 
>    __ZN7WebCoreL11enabledUndoERNS_5FrameEPNS_5EventENS_19EditorCommandSourceE
>    webkit.js:2898307
>    3. __cairo_spline_decompose_intowebkit.js:370173
>    4. __cairo_spline_decompose_intowebkit.js:370139
>    5. __cairo_spline_decompose_intowebkit.js:370133
>    6. __cairo_spline_decompose_intowebkit.js:370133
>    7. __cairo_spline_decomposewebkit.js:369909
>    8. __cairo_filler_curve_towebkit.js:329378
>    9. __cairo_path_fixed_interpretwebkit.js:331535
>    10. __cairo_path_fixed_fill_to_polygonwebkit.js:329220
>    11. __cairo_clip_get_polygonwebkit.js:296098
>    12. _clip_and_composite_boxes1278webkit.js:367803
>    13. __cairo_spans_compositor_fillwebkit.js:367435
>    14. __cairo_compositor_fillwebkit.js:299773
>    15. __cairo_image_surface_fillwebkit.js:323907
>    16. __cairo_surface_fillwebkit.js:377439
>    17. __cairo_gstate_fillwebkit.js:311587
>    18. __cairo_default_context_fillwebkit.js:302137
>    19. _cairo_fillwebkit.js:392852
>    20. 
>    
> __ZN7WebCoreL25drawPatternToCairoContextEP6_cairoP14_cairo_patternRKNS_9FloatRectEf
>    webkit.js:2589632
>    21. 
>    
> __ZN7WebCore20PlatformContextCairo20drawSurfaceToContextEP14_cairo_surfaceRKNS_9FloatRectES5_PNS_15GraphicsContextE
>    webkit.js:2589597
>    22. 
>    
> __ZN7WebCore11BitmapImage4drawEPNS_15GraphicsContextERKNS_9FloatRectES5_NS_10ColorSpaceENS_17CompositeOperatorENS_9BlendModeENS_27ImageOrientationDescriptionE
>    webkit.js:2582488
>    23. 
>    
> __ZN7WebCore15GraphicsContext9drawImageEPNS_5ImageENS_10ColorSpaceERKNS_9FloatRectES6_NS_17CompositeOperatorENS_9BlendModeENS_27ImageOrientationDescriptionEb
>    webkit.js:2659116
>    24. 
>    
> __ZN7WebCore11ImageBuffer4drawEPNS_15GraphicsContextENS_10ColorSpaceERKNS_9FloatRectES6_NS_17CompositeOperatorENS_9BlendModeEb
>    webkit.js:2587143
>    25. 
>    
> __ZN7WebCore15GraphicsContext15drawImageBufferEPNS_11ImageBufferENS_10ColorSpaceERKNS_9FloatRectES6_NS_17CompositeOperatorENS_9BlendModeEb
>    webkit.js:2659343
>    26. 
>    
> __ZN7WebCore10ShadowBlur15drawLayerPiecesEPNS_15GraphicsContextERKNS_9FloatRectERKNS_11RoundedRect5RadiiERKNS_7IntSizeESC_NS0_15ShadowDirectionE
>    webkit.js:2685411
>    27. 
>    
> __ZN7WebCore10ShadowBlur24drawRectShadowWithTilingEPNS_15GraphicsContextERKNS_9FloatRectERKNS_11RoundedRect5RadiiERKNS_7IntSizeESC_
>    webkit.js:2683998
>    28. 
>    
> __ZN7WebCore10ShadowBlur14drawRectShadowEPNS_15GraphicsContextERKNS_9FloatRectERKNS_11RoundedRect5RadiiE
>    webkit.js:2683682
>    29. 
>    
> __ZN7WebCore15GraphicsContext15fillRoundedRectERKNS_7IntRectERKNS_7IntSizeES6_S6_S6_RKNS_5ColorENS_10ColorSpaceE
>    webkit.js:2586467
>    30. 
>    
> __ZN7WebCore15GraphicsContext15fillRoundedRectERKNS_11RoundedRectERKNS_5ColorENS_10ColorSpaceENS_9BlendModeE
>    webkit.js:2659729
>    31. 
>    
> __ZN7WebCore20RenderBoxModelObject14paintBoxShadowERKNS_9PaintInfoERKNS_10LayoutRectEPKNS_11RenderStyleENS_11ShadowStyleEbb
>    webkit.js:2034044
>    32. 
>    
> __ZN7WebCore9RenderBox19paintBoxDecorationsERNS_9PaintInfoERKNS_11LayoutPointE
>    webkit.js:1996884
>    33. 
>    __ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoERKNS_11LayoutPointE
>    webkit.js:1924921
>    34. __ZN7WebCore11RenderBlock5paintERNS_9PaintInfoERKNS_11LayoutPointE
>    webkit.js:1922682
>    35. 
>    
> __ZN7WebCore11RenderLayer27paintBackgroundForFragmentsERKN3WTF6VectorINS_13LayerFragmentELj1ENS1_15CrashOnOverflowEEEPNS_15GraphicsContextES9_RKNS_10LayoutRectEbRKNS0_17LayerPaintingInfoEjPNS_12RenderObjectE
>    webkit.js:2140976
>    36. 
>    
> __ZN7WebCore11RenderLayer18paintLayerContentsEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2139294
>    37. 
>    
> __ZN7WebCore11RenderLayer31paintLayerContentsAndReflectionEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2138828
>    38. 
>    
> __ZN7WebCore11RenderLayer10paintLayerEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2137951
>    39. 
>    
> __ZN7WebCore11RenderLayer9paintListEPN3WTF6VectorIPS0_Lj0ENS1_15CrashOnOverflowEEEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2141104
>    40. 
>    
> __ZN7WebCore11RenderLayer18paintLayerContentsEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2139400
>    41. 
>    
> __ZN7WebCore11RenderLayer31paintLayerContentsAndReflectionEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2138828
>    42. 
>    
> __ZN7WebCore11RenderLayer10paintLayerEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2137951
>    43. 
>    
> __ZN7WebCore11RenderLayer9paintListEPN3WTF6VectorIPS0_Lj0ENS1_15CrashOnOverflowEEEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2141104
>    44. 
>    
> __ZN7WebCore11RenderLayer18paintLayerContentsEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2139400
>    45. 
>    
> __ZN7WebCore11RenderLayer31paintLayerContentsAndReflectionEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2138828
>    46. 
>    
> __ZN7WebCore11RenderLayer10paintLayerEPNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj
>    webkit.js:2137951
>    47. 
>    
> __ZN7WebCore11RenderLayer5paintEPNS_15GraphicsContextERKNS_10LayoutRectEjPNS_12RenderObjectEPNS_12RenderRegionEj
>    webkit.js:2137604
>    48. 
>    __ZN7WebCore9FrameView13paintContentsEPNS_15GraphicsContextERKNS_7IntRectE
>    webkit.js:2524510
>    49. __ZN7WebCore10ScrollView5paintEPNS_15GraphicsContextERKNS_7IntRectE
>    webkit.js:2776713
>    50. __ZN7WebCore14ChromeClientJS5paintEPNS_5TimerIS0_EE
>    webkit.js:3105032
>    51. 
>    __ZN7WebCore14ChromeClientJS29invalidateContentsAndRootViewERKNS_7IntRectEb
>    webkit.js:3106334
>    52. __ZN7WebCore6Chrome29invalidateContentsAndRootViewERKNS_7IntRectEb
>    webkit.js:2470075
>    53. __ZN7WebCore10ScrollView23repaintContentRectangleERKNS_7IntRectEb
>    webkit.js:2776145
>    54. __ZN7WebCore9FrameView18doDeferredRepaintsEvwebkit.js:2521516
>    55. __ZN7WebCore9FrameView19endDeferredRepaintsEvwebkit.js:2517917
>    56. __ZN7WebCore9FrameView6layoutEbwebkit.js:2516637
>    57. __ZN7WebCore9FrameView37updateLayoutAndStyleIfNeededRecursiveEv
>    webkit.js:2524735
>    58. __ZN7WebCore14ChromeClientJS5paintEPNS_5TimerIS0_EE
>    webkit.js:3104890
>    59. 
>    __ZN7WebCore14ChromeClientJS29invalidateContentsAndRootViewERKNS_7IntRectEb
>    webkit.js:3106334
>    60. __ZN7WebCore6Chrome29invalidateContentsAndRootViewERKNS_7IntRectEb
>    webkit.js:2470075
>    61. __ZN7WebCore9FrameView14invalidateRectERKNS_7IntRectE
>    webkit.js:2513833
>    62. 
>    
> __ZThn40_N7WebCore9FrameView23invalidateScrollbarRectEPNS_9ScrollbarERKNS_7IntRectE
>    webkit.js:2523162
>    63. 
>    
> __ZN7WebCore14ScrollableArea19invalidateScrollbarEPNS_9ScrollbarERKNS_7IntRectE
>    webkit.js:2767909
>    64. __ZN7WebCore9Scrollbar14invalidateRectERKNS_7IntRectE
>    webkit.js:2770328
>    65. __ZN7WebCore9Scrollbar10invalidateEvwebkit.js:2221663
>    66. 
>    
> __ZN7WebCore14ScrollableArea24setScrollbarOverlayStyleENS_21ScrollbarOverlayStyleE
>    webkit.js:2767897
>    67. 
>    
> __ZThn40_N7WebCore10ScrollView24setScrollbarOverlayStyleENS_21ScrollbarOverlayStyleE
>    webkit.js:2775744
>    68. 
>    
> __ZN7WebCore14ScrollableArea15didAddScrollbarEPNS_9ScrollbarENS_20ScrollbarOrientationE
>    webkit.js:2767708
>    69. 
>    
> __ZThn40_N7WebCore9FrameView15didAddScrollbarEPNS_9ScrollbarENS_20ScrollbarOrientationE
>    webkit.js:2526284
>    70. __ZN7WebCore10ScrollView23setHasVerticalScrollbarEbPb
>    webkit.js:2772320
>    71. __ZN7WebCore10ScrollView16updateScrollbarsERKNS_7IntSizeE
>    webkit.js:2772579
>    72. 
>    __ZN7WebCore10ScrollView17setScrollbarModesENS_13ScrollbarModeES1_bb
>    webkit.js:2772436
>    73. __ZN7WebCore9FrameView6layoutEbwebkit.js:2516304
>    74. __ZN7WebCore8Document13implicitCloseEvwebkit.js:1283487
>    75. __ZN7WebCore11FrameLoader14checkCompletedEvwebkit.js:979836
>    76. __ZN7WebCore11FrameLoader15finishedParsingEvwebkit.js:977943
>    77. __ZN7WebCore8Document15finishedParsingEvwebkit.js:1294083
>    78. __ZN7WebCore20HTMLConstructionSite15finishedParsingEv
>    webkit.js:1164661
>    79. __ZN7WebCore15HTMLTreeBuilder8finishedEvwebkit.js:1225675
>    <li title="" style="padding:0px 0px 0px 14px;margin-top:1px;word-wrap:
>
> ...
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to