gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.25k stars 267 forks source link

Compilation failure when building unit tests on M1Pro #229

Closed drekka closed 1 year ago

drekka commented 1 year ago

I'm building the unit tests for my project on my M1Pro based machine and it's currently failing to build. The errors appear to be related to the Clark framework used by MarkdownUI and the fact that the test architecture is arm64.

Undefined symbols for architecture arm64:
  "___ubsan_handle_add_overflow", referenced from:
      _url_match in cmark-gfm.o
      _postprocess_text in cmark-gfm.o
      _cmark_chunk_to_cstr in cmark-gfm.o
      _S_process_line in cmark-gfm.o
      _S_advance_offset in cmark-gfm.o
      _open_new_blocks in cmark-gfm.o
      _add_text_to_container in cmark-gfm.o
      ...
  "___ubsan_handle_builtin_unreachable", referenced from:
      _alloc_arena_chunk in cmark-gfm.o
      _add_child in cmark-gfm.o
      _add_text_to_container in cmark-gfm.o
      _parse_html_block_prefix in cmark-gfm.o
      _finalize in cmark-gfm.o
      _add_line in cmark-gfm.o
      _cmark_chunk_rtrim in cmark-gfm.o
      ...
  "___ubsan_handle_divrem_overflow", referenced from:
      _arena_calloc in cmark-gfm.o
      _S_advance_offset in cmark-gfm.o
      _S_find_first_nonspace in cmark-gfm.o
      _add_line in cmark-gfm.o
      _cmark_strbuf_grow in cmark-gfm.o
      _houdini_unescape_ent in cmark-gfm.o
      _S_lookup in cmark-gfm.o
      ...
  "___ubsan_handle_load_invalid_value", referenced from:
      _postprocess in cmark-gfm.o
      _cmark_manage_extensions_special_characters in cmark-gfm.o
      _cmark_parse_file in cmark-gfm.o
      _S_parser_feed in cmark-gfm.o
      _S_process_line in cmark-gfm.o
      _cmark_parser_is_blank in cmark-gfm.o
      _cmark_parser_has_partially_consumed_tab in cmark-gfm.o
      ...
  "___ubsan_handle_mul_overflow", referenced from:
      _parse_list_marker in cmark-gfm.o
      _houdini_unescape_ent in cmark-gfm.o
  "___ubsan_handle_negate_overflow", referenced from:
      _url_match in cmark-gfm.o
      _postprocess_text in cmark-gfm.o
      _handle_newline in cmark-gfm.o
      _adjust_subj_node_newlines in cmark-gfm.o
      _cmark_utf8proc_check in cmark-gfm.o
      _utf8proc_valid in cmark-gfm.o
      _utf8proc_charlen in cmark-gfm.o
      ...
  "___ubsan_handle_out_of_bounds", referenced from:
      _sd_autolink_issafe in cmark-gfm.o
      _cmark_isspace in cmark-gfm.o
      _cmark_ispunct in cmark-gfm.o
      _cmark_isalnum in cmark-gfm.o
      _cmark_isdigit in cmark-gfm.o
      _cmark_isalpha in cmark-gfm.o
      _S_render_node in cmark-gfm.o
      ...
  "___ubsan_handle_pointer_overflow", referenced from:
      _arena_calloc in cmark-gfm.o
      _arena_realloc in cmark-gfm.o
      _url_match in cmark-gfm.o
      _www_match in cmark-gfm.o
      _sd_autolink_issafe in cmark-gfm.o
      _check_domain in cmark-gfm.o
      _autolink_delim in cmark-gfm.o
      ...
  "___ubsan_handle_shift_out_of_bounds", referenced from:
      _S_process_line in cmark-gfm.o
      _finalize_document in cmark-gfm.o
      _open_new_blocks in cmark-gfm.o
      _cmark_version in cmark-gfm.o
      _cmark_render_commonmark_with_mem in cmark-gfm.o
      _S_render_node in cmark-gfm.o
      _shortest_unused_backtick_sequence in cmark-gfm.o
      ...
  "___ubsan_handle_sub_overflow", referenced from:
      _url_match in cmark-gfm.o
      _www_match in cmark-gfm.o
      _postprocess_text in cmark-gfm.o
      _S_process_line in cmark-gfm.o
      _S_advance_offset in cmark-gfm.o
      _open_new_blocks in cmark-gfm.o
      _add_text_to_container in cmark-gfm.o
      ...
  "___ubsan_handle_type_mismatch_v1", referenced from:
      _cmark_arena_push in cmark-gfm.o
      _alloc_arena_chunk in cmark-gfm.o
      _cmark_arena_pop in cmark-gfm.o
      _cmark_arena_reset in cmark-gfm.o
      _arena_calloc in cmark-gfm.o
      _arena_realloc in cmark-gfm.o
      _postprocess in cmark-gfm.o
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to reproduce

  1. Add MarkdownUI to a project with unit tests.
  2. Built the test target.

Version information

gonzalezreal commented 1 year ago

Hi @drekka,

This is very strange, as MarkdownUI is distributed as a source code package, even cmark-gfm, so there shouldn't be any hardware architecture issues.

In any case, I tried to reproduce it following the steps you mentioned above, and everything is working fine.

Could you please provide an Xcode project that reproduces the issue in an isolated way? This way, we can discard any problems caused by your project configuration.

drekka commented 1 year ago

Figured it out, I had to have the address sanitizer turned on. Could this be an issue with the mark library? If I turn the sanitiser off the errors come back.

gonzalezreal commented 1 year ago

It is hard to tell without a project reproducing the issue in isolation. As mentioned, I cannot reproduce the issue following your steps. Therefore, there is little I can do from my side.

gonzalezreal commented 1 year ago

Closing due to staleness. If this is still an issue, please provide a project that reproduces the problem in an isolated way.