Opened 4 years ago

Closed 2 years ago

#15827 closed bug (fixed)

memset is causing infinite recursion with clang build

Reported by: X512 Owned by: nobody
Priority: normal Milestone: R1/beta4
Component: System/libroot.so Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: x86-64

Description

This is hrev54001 x86_64 clang/lld build.

Clang produce memset call inside memset_small that is used by memset implementation causing infinite recursion (https://git.haiku-os.org/haiku/tree/src/system/libroot/posix/string/arch/x86_64/arch_string.cpp#n213).

This problem is causing crash in runtime_loader of init process and boot fail.

Change History (7)

comment:1 by waddlesplash, 4 years ago

Probably we need to compile arch_string with -disable-simplify-libcalls, or maybe even all of libroot with it.

comment:2 by waddlesplash, 4 years ago

Actually, just putting it in string/Jamfile may be the right place. That way the rest of libroot can still take advantage of those optimizations.

comment:3 by waddlesplash, 4 years ago

Eh, on second thought, it seems kind of dangerous to do those optimizations in the kernel or userland libraries at all; it's probably much better if we just add that flag across the board when compiling with Clang.

comment:4 by pulkomandy, 4 years ago

Can't we just call builtin_memset instead of having all this code, and let gcc/clang do the right thing?

Version 0, edited 4 years ago by pulkomandy (next)

comment:5 by X512, 4 years ago

I tested __builtin_memset and it generate code that call regular memset.

Last edited 4 years ago by X512 (previous) (diff)

comment:6 by waddlesplash, 4 years ago

Uh, GCC/Clang __builtin_memset() only gets "inlined" for small copies (i.e. I think something like 64 bytes is the maximum), it is very primitive and not at all optimized for large (i.e. KBs/MBs) sets. We have to provide a memset one way or another.

comment:7 by waddlesplash, 2 years ago

Milestone: UnscheduledR1/beta4
Resolution: fixed
Status: newclosed

Fixed in hrev55661.

Note: See TracTickets for help on using tickets.