{"action":"created","issue":{"url":"https://api.github.com/repos/darktable-org/darktable/issues/1783","repository_url":"https://api.github.com/repos/darktable-org/darktable","labels_url":"https://api.github.com/repos/darktable-org/darktable/issues/1783/labels{/name}","comments_url":"https://api.github.com/repos/darktable-org/darktable/issues/1783/comments","events_url":"https://api.github.com/repos/darktable-org/darktable/issues/1783/events","html_url":"https://github.com/darktable-org/darktable/pull/1783","id":375113109,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2NjM0NzEx","number":1783,"title":"WIP: Fix segfault when drawing a path for a mask","user":{"login":"cryptomilk","id":545480,"node_id":"MDQ6VXNlcjU0NTQ4MA==","avatar_url":"https://avatars1.githubusercontent.com/u/545480?v=4","gravatar_id":"","url":"https://api.github.com/users/cryptomilk","html_url":"https://github.com/cryptomilk","followers_url":"https://api.github.com/users/cryptomilk/followers","following_url":"https://api.github.com/users/cryptomilk/following{/other_user}","gists_url":"https://api.github.com/users/cryptomilk/gists{/gist_id}","starred_url":"https://api.github.com/users/cryptomilk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cryptomilk/subscriptions","organizations_url":"https://api.github.com/users/cryptomilk/orgs","repos_url":"https://api.github.com/users/cryptomilk/repos","events_url":"https://api.github.com/users/cryptomilk/events{/privacy}","received_events_url":"https://api.github.com/users/cryptomilk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-29T16:47:21Z","updated_at":"2018-10-29T22:03:13Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/darktable-org/darktable/pulls/1783","html_url":"https://github.com/darktable-org/darktable/pull/1783","diff_url":"https://github.com/darktable-org/darktable/pull/1783.diff","patch_url":"https://github.com/darktable-org/darktable/pull/1783.patch"},"body":"I'm trying to address the segfault which is attached at the end. I see several problems here. The code uses `int` instead of `size_t` for array access and allocating memory. This could be a problem as signed integer overflows are undefined in the C specification. For size calculations an unsigned integer should be use, also that the optimize will understand the code better.\r\n\r\n```\r\nThread 1 (Thread 0x7fcf14e19c80 (LWP 25895)):\r\n#0  0x00007fcf1f1b38da in __waitpid (pid=pid@entry=32301, stat_loc=stat_loc@entry=0x0, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30\r\n        resultvar = 18446744073709551104\r\n        sc_cancel_oldtype = 0\r\n#1  0x00007fcf1f4d2e60 in _dt_sigsegv_handler (param=11) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/common/system_signal_handling.c:118\r\n        pid = 32301\r\n        name_used = 0x55ceca05bc90 \"/tmp/darktable_bt_VU5KRZ.txt\"\r\n        fout = <optimized out>\r\n        delete_file = 0\r\n        datadir = \"/usr/share/darktable\", '\\000' <repeats 4075 times>\r\n        pid_arg = 0x55ceca4e41a0 \"25895\"\r\n        comm_arg = 0x55ceca45ef30 \"/usr/share/darktable/gdb_commands\"\r\n        log_arg = 0x55ceca4adac0 \"set logging on /tmp/darktable_bt_VU5KRZ.txt\"\r\n#2  0x00007fcf1f1b3f70 in <signal handler called> () at /lib64/libpthread.so.0\r\n#3  0x00007fcf1f5320db in _path_find_self_intersection (border_count=8567, border=0x7fcdd4b0d010, nb_corners=3, inter=0x55cec98cb610) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/develop/masks/path.c:430\r\n        xx = <optimized out>\r\n        yy = <optimized out>\r\n        v = {<optimized out>, 0, 0}\r\n        j = 435\r\n        i = 9\r\n        ii = 9\r\n        inter_count = 0\r\n        xmax = <optimized out>\r\n        wb = 719\r\n        xmin = 163\r\n        ymax = <optimized out>\r\n        ss = <optimized out>\r\n        binter = 0x7fce18b81010\r\n        lastx = <optimized out>\r\n        ymin = 402\r\n        posextr = {4142, 9, 21, 4446}\r\n        extra = 0x55cec992d430\r\n        lasty = <optimized out>\r\n        start2 = 250145551.227718\r\n        wd = <optimized out>\r\n        ht = <optimized out>\r\n        nb = 3\r\n        dpoints = <optimized out>\r\n        dborder = <optimized out>\r\n        intersections = 0x55cec98cb610\r\n        dx = <optimized out>\r\n        dy = <optimized out>\r\n        border_init = 0x55cec98c0e00\r\n        cw = <optimized out>\r\n        inter_count = 0\r\n#4  0x00007fcf1f5320db in _path_get_points_border (dev=dev@entry=0x55cec7b54fe0, form=form@entry=0x55cec9e48e40, prio_max=prio_max@entry=999999, pipe=0x55cec7b55df0, points=points@entry=0x55cec90a3810, points_count=points_count@entry=0x55cec90a3818, border=0x55cec90a3820, border_count=0x55cec90a3828, source=0) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/develop/masks/path.c:681\r\n        start2 = 250145551.227718\r\n        wd = <optimized out>\r\n        ht = <optimized out>\r\n        nb = 3\r\n        dpoints = <optimized out>\r\n        dborder = <optimized out>\r\n        intersections = 0x55cec98cb610\r\n        dx = <optimized out>\r\n        dy = <optimized out>\r\n        border_init = 0x55cec98c0e00\r\n        cw = <optimized out>\r\n        inter_count = 0\r\n#5  0x00007fcf1f5345b4 in dt_path_get_points_border (source=0, border_count=0x55cec90a3828, border=0x55cec90a3820, points_count=0x55cec90a3818, points=0x55cec90a3810, form=0x55cec9e48e40, dev=0x55cec7b54fe0) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/develop/masks/path.c:834\r\n#6  0x00007fcf1f5345b4 in dt_masks_get_points_border (dev=0x55cec7b54fe0, form=form@entry=0x55cec9e48e40, points=points@entry=0x55cec90a3810, points_count=points_count@entry=0x55cec90a3818, border=border@entry=0x55cec90a3820, border_count=border_count@entry=0x55cec90a3828, source=0) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/develop/masks/masks.c:507\r\n#7  0x00007fcf1f5347f0 in dt_masks_gui_form_create (form=form@entry=0x55cec9e48e40, gui=gui@entry=0x55cec8bd7800, index=index@entry=0) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/develop/masks/masks.c:232\r\n        gpt = 0x55cec90a3810\r\n#8  0x00007fcf1f54464d in dt_path_events_mouse_moved (pzx=<optimized out>, pzy=<optimized out>, form=form@entry=0x55cec9e48e40, gui=gui@entry=0x55cec8bd7800, index=index@entry=0, parentid=0, which=0, pressure=1, module=<optimized out>) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/develop/masks/path.c:1651\r\n        pos2 = <optimized out>\r\n        point2 = <optimized out>\r\n        ht = <optimized out>\r\n        pts = {351.299561, 561.158325}\r\n        dx = <optimized out>\r\n        point = <optimized out>\r\n        wd = <optimized out>\r\n        dy = <optimized out>\r\n        zoom = <optimized out>\r\n        closeup = <optimized out>\r\n        zoom_scale = 1.78666663\r\n        gpt = <optimized out>\r\n        nb = <optimized out>\r\n        in = -944418848\r\n        inb = 21966\r\n        near = 525376325\r\n        ins = 32719\r\n#9  0x00007fcf1f5455cd in dt_masks_events_mouse_moved (module=<optimized out>, x=x@entry=730.38671875, y=y@entry=1003.7430419921875, pressure=pressure@entry=1, which=which@entry=0) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/develop/masks/masks.c:1290\r\n        gui = 0x55cec8bd7800\r\n        form = 0x55cec9e48e40\r\n        pzx = 0.258517683\r\n        pzy = 0.624218285\r\n        rep = 0\r\n#10 0x00007fcf0c032bea in mouse_moved (self=0x55cec7b539c0, x=<optimized out>, y=<optimized out>, pressure=1, which=0) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/views/darkroom.c:1972\r\n        capwd = <optimized out>\r\n        capht = <optimized out>\r\n        dev = 0x55cec7b54fe0\r\n        mouse_over_id = <optimized out>\r\n        ctl = 0x55cec6ca4ae0\r\n        width_i = <optimized out>\r\n        height_i = <optimized out>\r\n        offx = <optimized out>\r\n        offy = <optimized out>\r\n        handled = 0\r\n#11 0x00007fcf1f56fa2d in mouse_moved (w=w@entry=0x55cec78fb450 [GtkDrawingArea], event=0x55cec943ac70, user_data=<optimized out>) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/gui/gtk.c:894\r\n        pressure = 1\r\n        device = <optimized out>\r\n        x = 120\r\n        y = 0\r\n#16 0x00007fcf1df0233f in <emit signal ??? on instance 0x55cec78fb450 [GtkDrawingArea]> (instance=instance@entry=0x55cec78fb450, signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3447\r\n        var_args = {{gp_offset = 32, fp_offset = 48, overflow_arg_area = 0x7fff57b15530, reg_save_area = 0x7fff57b15470}}\r\n    #12 0x00007fcf1e6df6fb in _gtk_marshal_BOOLEAN__BOXED (closure=0x55cec7b14970, return_value=0x7fff57b15210, n_param_values=<optimized out>, param_values=0x7fff57b15270, invocation_hint=<optimized out>, marshal_data=<optimized out>) at gtkmarshalers.c:83\r\n                cc = 0x55cec7b14970\r\n                data1 = 0x55cec78fb450\r\n                data2 = <optimized out>\r\n                callback = 0x7fcf1f56f9d0 <mouse_moved>\r\n                v_return = <optimized out>\r\n                __func__ = \"_gtk_marshal_BOOLEAN__BOXED\"\r\n    #13 0x00007fcf1dee5b6d in g_closure_invoke (closure=0x55cec7b14970, return_value=0x7fff57b15210, n_param_values=2, param_values=0x7fff57b15270, invocation_hint=0x7fff57b151f0) at gclosure.c:810\r\n                marshal = 0x7fcf1e6df690 <_gtk_marshal_BOOLEAN__BOXED>\r\n                marshal_data = 0x0\r\n                in_marshal = 0\r\n                real_closure = 0x55cec7b14950\r\n                __func__ = \"g_closure_invoke\"\r\n    #14 0x00007fcf1def8cb3 in signal_emit_unlocked_R (node=node@entry=0x55cec6e13320, detail=detail@entry=0, instance=instance@entry=0x55cec78fb450, emission_return=emission_return@entry=0x7fff57b153a0, instance_and_params=instance_and_params@entry=0x7fff57b15270) at gsignal.c:3635\r\n                tmp = <optimized out>\r\n                handler = 0x55cec7afc8c0\r\n                accumulator = 0x55cec6e42680\r\n                emission = {next = 0x0, instance = 0x55cec78fb450, ihint = {signal_id = 98, detail = 0, run_type = G_SIGNAL_RUN_FIRST}, state = EMISSION_RUN, chain_type = 0x4 [void]}\r\n                class_closure = 0x55cec6e40b40\r\n                hlist = <optimized out>\r\n                handler_list = 0x55cec7afc8c0\r\n                return_accu = 0x7fff57b15210\r\n                accu = {g_type = 0x14 [gboolean], data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}\r\n                signal_id = 98\r\n                max_sequential_handler_number = 383454\r\n                return_value_altered = 0\r\n    #15 0x00007fcf1df013d3 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fff57b15450) at gsignal.c:3401\r\n                return_value = {g_type = 0x14 [gboolean], data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}\r\n                error = 0x0\r\n                rtype = 0x14 [gboolean]\r\n                static_scope = 0\r\n                instance_and_params = 0x7fff57b15270\r\n                signal_return_type = <optimized out>\r\n                param_values = 0x7fff57b15288\r\n                node = <optimized out>\r\n                i = <optimized out>\r\n                n_params = <optimized out>\r\n                __func__ = \"g_signal_emit_valist\"\r\n#17 0x00007fcf1e68d924 in gtk_widget_event_internal (widget=widget@entry=0x55cec78fb450 [GtkDrawingArea], event=event@entry=0x55cec943ac70) at gtkwidget.c:7744\r\n        signal_num = <optimized out>\r\n        return_val = <optimized out>\r\n        handled = 0\r\n        __func__ = \"gtk_widget_event_internal\"\r\n#18 0x00007fcf1e68fa3a in gtk_widget_event (widget=widget@entry=0x55cec78fb450 [GtkDrawingArea], event=event@entry=0x55cec943ac70) at gtkwidget.c:7314\r\n        __func__ = \"gtk_widget_event\"\r\n#19 0x00007fcf1e54e5d6 in propagate_event_up (topmost=<optimized out>, event=<optimized out>, widget=0x55cec78fb450 [GtkDrawingArea]) at gtkmain.c:2582\r\n        tmp = <optimized out>\r\n        handled_event = <optimized out>\r\n        handled_event = 0\r\n#20 0x00007fcf1e54e5d6 in propagate_event (widget=<optimized out>, event=0x55cec943ac70, captured=<optimized out>, topmost=0x0) at gtkmain.c:2685\r\n        handled_event = 0\r\n#21 0x00007fcf1e550693 in gtk_main_do_event (event=<optimized out>) at gtkmain.c:1915\r\n        grab_widget = <optimized out>\r\n        window_group = <optimized out>\r\n        rewritten_event = <optimized out>\r\n        device = <optimized out>\r\n        tmp_list = <optimized out>\r\n        event_widget = <optimized out>\r\n        topmost_widget = <optimized out>\r\n        event = 0x55cec943ac70\r\n        __func__ = \"gtk_main_do_event\"\r\n        __func__ = \"gtk_main_do_event\"\r\n#22 0x00007fcf1e2462a5 in _gdk_event_emit (event=event@entry=0x55cec943ac70) at gdkevents.c:73\r\n#23 0x00007fcf1e276d62 in gdk_event_source_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at gdkeventsource.c:367\r\n        display = <optimized out>\r\n        event = 0x55cec943ac70\r\n#24 0x00007fcf1f824c15 in g_main_dispatch (context=0x55cec6ca7b10) at gmain.c:3182\r\n        dispatch = 0x7fcf1e276d40 <gdk_event_source_dispatch>\r\n        prev_source = 0x0\r\n        was_in_call = 0\r\n        user_data = 0x0\r\n        callback = 0x0\r\n        cb_funcs = 0x0\r\n        cb_data = 0x0\r\n        need_destroy = <optimized out>\r\n        source = 0x55cec6d6d560\r\n        current = 0x55cec6c6c890\r\n        i = 0\r\n        __func__ = \"g_main_dispatch\"\r\n#25 0x00007fcf1f824c15 in g_main_context_dispatch (context=context@entry=0x55cec6ca7b10) at gmain.c:3847\r\n#26 0x00007fcf1f824fd8 in g_main_context_iterate (context=0x55cec6ca7b10, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3920\r\n        max_priority = 0\r\n        timeout = 0\r\n        some_ready = 1\r\n        nfds = <optimized out>\r\n        allocated_nfds = 3\r\n        fds = 0x55cec813e970\r\n#27 0x00007fcf1f8252d2 in g_main_loop_run (loop=0x55cec7bf7100) at gmain.c:4116\r\n        __func__ = \"g_main_loop_run\"\r\n#28 0x00007fcf1e54f775 in gtk_main () at gtkmain.c:1323\r\n        loop = 0x55cec7bf7100\r\n#29 0x00007fcf1f5727aa in dt_gui_gtk_run (gui=<optimized out>) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/gui/gtk.c:1242\r\n        widget = <optimized out>\r\n        allocation = {x = 574, y = 24, width = 190, height = 690}\r\n#30 0x000055cec53060a2 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/darktable-ivybridge-2.5.0~git710.f0ad51b33-606.1.x86_64/src/main.c:83\r\n[Inferior 1 (process 25895) detached]\r\n```"},"comment":{"url":"https://api.github.com/repos/darktable-org/darktable/issues/comments/434097793","html_url":"https://github.com/darktable-org/darktable/pull/1783#issuecomment-434097793","issue_url":"https://api.github.com/repos/darktable-org/darktable/issues/1783","id":434097793,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDA5Nzc5Mw==","user":{"login":"TurboGit","id":467069,"node_id":"MDQ6VXNlcjQ2NzA2OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/467069?v=4","gravatar_id":"","url":"https://api.github.com/users/TurboGit","html_url":"https://github.com/TurboGit","followers_url":"https://api.github.com/users/TurboGit/followers","following_url":"https://api.github.com/users/TurboGit/following{/other_user}","gists_url":"https://api.github.com/users/TurboGit/gists{/gist_id}","starred_url":"https://api.github.com/users/TurboGit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TurboGit/subscriptions","organizations_url":"https://api.github.com/users/TurboGit/orgs","repos_url":"https://api.github.com/users/TurboGit/repos","events_url":"https://api.github.com/users/TurboGit/events{/privacy}","received_events_url":"https://api.github.com/users/TurboGit/received_events","type":"User","site_admin":false},"created_at":"2018-10-29T22:03:13Z","updated_at":"2018-10-29T22:03:13Z","author_association":"MEMBER","body":"Well, I agree with all of what you said (I know what an overflow is and the security issue it can bring) but yet the issue is unknown and probably not solved by your patch. I'm sure you'll be able to reproduce with it. So we need more information, more check, more  backtrace and a way to reproduce if possible."}}
{"actor":{"display_login":"TurboGit"}}