Opened 2 years ago

Closed 9 months 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/ Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: x86-64


This is hrev54001 x86_64 clang/lld build.

Clang produce memset call inside memset_small that is used by memset implementation causing infinite recursion (

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

Change History (7)

comment:1 by waddlesplash, 2 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, 2 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, 2 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, 2 years ago

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

Last edited 2 years ago by pulkomandy (previous) (diff)

comment:5 by X512, 2 years ago

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

Version 0, edited 2 years ago by X512 (next)

comment:6 by waddlesplash, 2 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, 9 months ago

Milestone: UnscheduledR1/beta4
Resolution: fixed
Status: newclosed

Fixed in hrev55661.

Note: See TracTickets for help on using tickets.