[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

tree conflicts: segfault in merge_dir_opened()

From: Neels Janosch Hofmeyr <neels_at_elego.de>
Date: Sat, 16 Aug 2008 04:33:58 +0200

Hi tree-conflicts folks,

I discovered this case while writing a new set of tests for tree
conflict detection, which tests for both file and directory victims in
tree structures of various depths.

I am faced with a segmentation fault in

        libsvn_client/merge.c: merge_dir_opened()

when it is passed an adm_access == NULL.

This occurs when a merge tries to add a file to a *directory* that
existed in a common ancestry, but was deleted on the local branch.

First, in subversion/libsvn_client/repos_diff.c, open_directory() looks
up this previously deleted directory, using get_path_access(). It yields
an adm_access == NULL, which is passed to merge_dir_opened().

On trunk, merge_dir_opened() is empty. No segmentation fault occurs.

On the tree-conflicts branch, merge_dir_opened() contains tree conflict
detection code, which dereferences adm_access (== NULL).

If I fix the first segmentation fault, the subsequent call to
tree_conflict() causes another segmentation fault, since it too
dereferences adm_access.

For now, I am using a simple patch that simply skips the tree conflict
detection in merge_dir_opened() when adm_access == NULL (see
merge_patch.diff), and that's probably stupid.

To reproduce the segmentation fault, apply the attached diff
my_tc_tests.diff to today's tree-conflicts branch (r32499) and run my
merge test `merge_tests.py 101'.

For more details, see the attached backtrace.txt.

Note: my_tc_tests.diff contains patches which I am about to post to the
list separately. No need to discuss them here.

Thanks a lot for any suggestions!

Neels

-- 
Neels Hofmeyr -- elego Software Solutions GmbH
Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23458696  mobile: +49 177 2345869  fax: +49 30 23458695
http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelsreg: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194



The segmentation fault occurs in merge_tests.py:101,
subtest local_tree_del_incoming_leaf_edit.

It occurs when calling svn_wc_entry with parameter adm_access==NULL,
when trying to merge the addition of the file

  DD/D1/D2/epsilon

, while in the local working copy, on another branch sharing ancestry,
a removal of DD/D1 has been committed.

It occurs while trying to get adm_access information on DD/D1/D2.

My guess is that adm_access becomes NULL since neither D2 nor its parent
D1 are present on the branch.

neels_at_dub:/arch/elego/svn/tc/subversion/tests/cmdline
$ ./merge_tests.py 101
<artificially exiting just before the segmentation fault:
 put `return None` in svntest/actions.py:2063, just after "8) Merge all">
PASS: merge_tests.py 101: tree conflicts on merge, local commit (tc 4-6)

neels_at_dub:/arch/elego/svn/tc/subversion/tests/cmdline
$ gdb /arch/elego/svn/tc/subversion/svn/svn
GNU gdb 6.8-debian
Copyright (C) 2008 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 "i486-linux-gnu"...

(gdb) run merge file:///arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/repositories/merge_tests-101/local_tree_del_incoming_leaf_edit/incoming svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local --config-dir /arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/local_tmp/config --password rayjandom --no-auth-cache --username jrandom
Starting program: /arch/elego/svn/tc/subversion/svn/svn merge file:///arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/repositories/merge_tests-101/local_tree_del_incoming_leaf_edit/incoming svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local --config-dir /arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/local_tmp/config --password rayjandom --no-auth-cache --username jrandom
[Thread debugging using libthread_db enabled]
Skipped missing target: 'svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/D/D1/delta'
Skipped missing target: 'svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/D/D1'
--- Merging r3 through r8 into 'svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local':
C svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/D
Skipped missing target: 'svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/F/alpha'
C svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/F
[New Thread 0xb7a8c6d0 (LWP 584)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7a8c6d0 (LWP 584)]
0x080ada84 in svn_wc__adm_retrieve_internal (adm_access=0xbfc76890, associated=0x0,
    path=0x829b5b0 "svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/DD/D1/D2", pool=0x82cc038) at subversion/libsvn_wc/lock.c:894
894 if (associated->set)
(gdb) bt
#0 0x080ada84 in svn_wc__adm_retrieve_internal (adm_access=0xbfc76890, associated=0x0,
    path=0x829b5b0 "svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/DD/D1/D2", pool=0x82cc038) at subversion/libsvn_wc/lock.c:894
#1 0x080a88fe in svn_wc_entry (entry=0xbfc768d8, path=0x829b5b0 "svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/DD/D1/D2",
    adm_access=0x0, show_hidden=1, pool=0x82cc038) at subversion/libsvn_wc/entries.c:1247
#2 0x08080d20 in merge_dir_opened (adm_access=0x0, path=0x829b5b0 "svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local/DD/D1/D2", rev=2,
    baton=0xbfc77348) at subversion/libsvn_client/merge.c:1531
#3 0x08091af2 in open_directory (path=0x829b480 "DD/D1/D2", parent_baton=0x82b6d28, base_revision=2, pool=0x829b3c0, child_baton=0x829b514)
    at subversion/libsvn_client/repos_diff.c:616
#4 0x081313dd in open_directory (path=0x829b480 "DD/D1/D2", parent_baton=0x82b6d20, base_revision=2, pool=0x829b3c0, child_baton=0x829b50c)
    at subversion/libsvn_delta/cancel.c:140
#5 0x081313dd in open_directory (path=0x829b480 "DD/D1/D2", parent_baton=0x82b6d18, base_revision=2, pool=0x829b3c0, child_baton=0xbfc76aa0)
    at subversion/libsvn_delta/cancel.c:140
#6 0x080e76df in update_entry (b=0x8207680, s_rev=2, s_path=0x829b438 "/local_tree_del_incoming_leaf_edit/incoming/DD/D1/D2", s_entry=0x82a6e08,
    t_path=0x829b4d0 "/local_tree_del_incoming_leaf_edit/incoming/DD/D1/D2", t_entry=0x82a73b8, dir_baton=0x82b6d18, e_path=0x829b480 "DD/D1/D2", info=0x0,
    wc_depth=svn_depth_infinity, requested_depth=svn_depth_infinity, pool=0x829b3c0) at subversion/libsvn_repos/reporter.c:830
#7 0x080e82a6 in delta_dirs (b=0x8207680, s_rev=2, s_path=0x82b6c58 "/local_tree_del_incoming_leaf_edit/incoming/DD/D1",
    t_path=0x82b6ce0 "/local_tree_del_incoming_leaf_edit/incoming/DD/D1", dir_baton=0x82b6d18, e_path=0x82b6ca0 "DD/D1", start_empty=0, wc_depth=svn_depth_infinity,
    requested_depth=svn_depth_infinity, pool=0x82b6be8) at subversion/libsvn_repos/reporter.c:1110
#8 0x080e77cf in update_entry (b=0x8207680, s_rev=2, s_path=0x82b6c58 "/local_tree_del_incoming_leaf_edit/incoming/DD/D1", s_entry=0x8296d90,
    t_path=0x82b6ce0 "/local_tree_del_incoming_leaf_edit/incoming/DD/D1", t_entry=0x8297320, dir_baton=0x8275448, e_path=0x82b6ca0 "DD/D1", info=0x0,
    wc_depth=svn_depth_infinity, requested_depth=svn_depth_infinity, pool=0x82b6be8) at subversion/libsvn_repos/reporter.c:837
#9 0x080e82a6 in delta_dirs (b=0x8207680, s_rev=2, s_path=0x8275398 "/local_tree_del_incoming_leaf_edit/incoming/DD",
    t_path=0x8275418 "/local_tree_del_incoming_leaf_edit/incoming/DD", dir_baton=0x8275448, e_path=0x82753d8 "DD", start_empty=0, wc_depth=svn_depth_infinity,
    requested_depth=svn_depth_infinity, pool=0x8275328) at subversion/libsvn_repos/reporter.c:1110
#10 0x080e77cf in update_entry (b=0x8207680, s_rev=2, s_path=0x8275398 "/local_tree_del_incoming_leaf_edit/incoming/DD", s_entry=0x8282360,
    t_path=0x8275418 "/local_tree_del_incoming_leaf_edit/incoming/DD", t_entry=0x82830c0, dir_baton=0x828ab38, e_path=0x82753d8 "DD", info=0x0, wc_depth=svn_depth_infinity,
    requested_depth=svn_depth_infinity, pool=0x8275328) at subversion/libsvn_repos/reporter.c:837
#11 0x080e82a6 in delta_dirs (b=0x8207680, s_rev=2, s_path=0x8265838 "/local_tree_del_incoming_leaf_edit/incoming",
    t_path=0x8207475 "/local_tree_del_incoming_leaf_edit/incoming", dir_baton=0x828ab38, e_path=0x819e96b "", start_empty=0, wc_depth=svn_depth_infinity,
    requested_depth=svn_depth_infinity, pool=0x8207200) at subversion/libsvn_repos/reporter.c:1110
#12 0x080e865e in drive (b=0x8207680, s_rev=2, info=0x8208e50, pool=0x8207200) at subversion/libsvn_repos/reporter.c:1174
#13 0x080e8a13 in finish_report (b=0x8207680, pool=0x8207200) at subversion/libsvn_repos/reporter.c:1241
#14 0x080e8ed7 in svn_repos_finish_report (baton=0x8207680, pool=0x8207200) at subversion/libsvn_repos/reporter.c:1365
#15 0x080dac25 in reporter_finish_report (reporter_baton=0x8208e18, pool=0x8207200) at subversion/libsvn_ra_local/ra_plugin.c:210
#16 0x08082a37 in drive_merge_report_editor (target_wcpath=0x81d19b0 "svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local",
    url1=0x81f3f38 "file:///arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/repositories/merge_tests-101/local_tree_del_incoming_leaf_edit/incoming", revision1=2,
    url2=0x81f40c8 "file:///arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/repositories/merge_tests-101/local_tree_del_incoming_leaf_edit/incoming", revision2=8,
    children_with_mergeinfo=0x81ef618, is_rollback=0, depth=svn_depth_infinity, notify_b=0xbfc773a0, adm_access=0x81d1e48, callbacks=0x8198520, merge_b=0xbfc77348,
    pool=0x8207200) at subversion/libsvn_client/merge.c:2791
#17 0x080865e6 in do_directory_merge (
    url1=0x81f3f38 "file:///arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/repositories/merge_tests-101/local_tree_del_incoming_leaf_edit/incoming", revision1=2,
    url2=0x81f40c8 "file:///arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/repositories/merge_tests-101/local_tree_del_incoming_leaf_edit/incoming", revision2=8,
    parent_entry=0x81d1f30, adm_access=0x81d1e48, depth=svn_depth_infinity, notify_b=0xbfc773a0, merge_b=0xbfc77348, pool=0x81e7198) at subversion/libsvn_client/merge.c:4912
#18 0x08087747 in do_merge (merge_sources=0x81f3b68, target=0x81d19b0 "svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local",
    target_entry=0x81d1f30, adm_access=0x81d1e48, sources_ancestral=1, sources_related=1, same_repos=1, ignore_ancestry=0, force=0, dry_run=0, record_only=0,
    depth=svn_depth_infinity, merge_options=0x0, ctx=0x81d07a8, pool=0x81d01e0) at subversion/libsvn_client/merge.c:5395
#19 0x08089d23 in svn_client_merge_peg3 (
    source=0x81d1690 "file:///arch/elego/svn/tc/subversion/tests/cmdline/svn-test-work/repositories/merge_tests-101/local_tree_del_incoming_leaf_edit/incoming",
    ranges_to_merge=0x81d1a40, peg_revision=0xbfc77524, target_wcpath=0x81d19b0 "svn-test-work/working_copies/merge_tests-101/local_tree_del_incoming_leaf_edit/local",
    depth=svn_depth_unknown, ignore_ancestry=0, force=0, record_only=0, dry_run=0, merge_options=0x0, ctx=0x81d07a8, pool=0x81d01e0) at subversion/libsvn_client/merge.c:6339
#20 0x08058d36 in svn_cl__merge (os=0x81d0380, baton=0xbfc77760, pool=0x81d01e0) at subversion/svn/merge-cmd.c:307
#21 0x080582d1 in main (argc=11, argv=0xbfc77894) at subversion/svn/main.c:1981

Received on 2008-08-16 04:36:27 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.