On 07/12/2011 10:56 AM, Taco Hoekwater wrote:
On 07/12/2011 09:11 AM, Hartmut Henkel wrote:

looks as if the macro package calls for a direction other than the
four implemented ones (TLT, TRT, LTL, RTT).

That is just a side-effect. I have deduced so far, that the problem is
that one of internal structures for \halign becomes trashed somewhere
in the process. That gives one of the nodes a bad field, which in turn
causes a bad attribute assignment to happen, resulting in the assertion
failure.

Revision 4327 (trunk) adds an assert() so that the actual problem is
discovered earlier (but luatex still crashes).

The problem is caused because the loop in bidi.lua is adding
stuff to node lists where it should not do so. I am not at all sure
what the correct fix is, but this replacement function for bidi.lua
makes the crash go away, at least:

local function process_node(head, group)
    local str, line

    head, str = node_string(head)

    line      = process_string(str, group)

    assert(#line == node.length(head))

    assign_levels(head, line)

    for n in node.traverse(head) do
        if n.id == glyph then
            local v = node.has_attribute(n, level_attribute)
            if v and odd(v) then
                local mirror = chardata[n.char].mirror
                if mirror then
                    n.char = mirror
                end
            end
        end

        local bdir = node.has_attribute(n, bdir_attribute)
        local edir = node.has_attribute(n, edir_attribute)
        local new
        node.slide(head)
        if bdir then
            if not n.prev and group == "" then
                while n and n.id ~= glyph do
                    n = n.next
                end
            end
            if not n.id == node.id('unset') then
              if bdir == 1 then     -- +TRT
head, new = node.insert_before(head, n, new_dir_node("+TRT"))
              elseif bdir == 3 then -- +TLT
head, new = node.insert_before(head, n, new_dir_node("+TLT"))
              end
            end
        end
        if edir then
            if not n.next and group == "" then
                while n and n.id ~= glyph do
                    n = n.prev
                end
            end
            if not n.id == node.id('unset') then
              if edir == 2 then     -- -TRT
head, new = node.insert_after(head, n, new_dir_node("-TRT"))
              elseif edir == 4 then -- -TLT
head, new = node.insert_after(head, n, new_dir_node("-TLT"))
              end
            end
        end
        if new then
            node.unset_attribute(new, bdir_attribute)
            node.unset_attribute(new, edir_attribute)
        end

    end

    return head
end

Reply via email to