On Tue, Jan 8, 2019 at 10:48 AM <singhal.an...@tcs.com> wrote: > > I have migrated a user module mod_example from 1.3 to 2.4. But when I try > to start the apache it is giving a segmentation fault and creating a core. > > Following is the stacktrace while debug: > t@1 (l@1) signal SEGV (no mapping at the fault address) in strlen at > 0xfefcceb8 > 0xfefcceb8: strlen+0x0018: ldub [%o2], %o1 > Current function is apr_pstrdup > 77 len = strlen(s) + 1; > (dbx) where > current thread: t@1 > [1] strlen(0x1, 0xed568, 0x1, 0xed558, 0x1, 0x0), at 0xfefcceb8 > =>[2] apr_pstrdup(a = 0xb8190, s = 0x1 "<bad address 0x00000001>"), line > 77 in "apr_strings.c" > [3] ap_add_module_commands(m = 0xfebc80d8, p = <value unavailable>), > line 546 in "config.c" > [4] ap_add_module(m = 0xfebc80d8, p = 0xb8190, sym_name = <value > unavailable>), at 0x5db30 > [5] ap_add_loaded_module(mod = 0xfebc80d8, p = 0xb8190, short_name = > 0xed510 "example_module"), line 713 in "config.c" > [6] load_module(cmd = 0xffbfec90, dummy = <value unavailable>, modname = > 0xed510 "example_module", filename = <value unavailable>), line 302 in > "mod_so.c" > > This is happening while loading a user module that I created: > LoadModule example_module modules/mod_example.so > > Please provide your valuable insight into it so that I can go forward. >
The info above is a bit limited in diagnosing the specifics of source code you didn't share, and we aren't that great at divining the invisible, so two thoughts for you; first build an httpd/apr/your module with CFLAGS -g -O0. Sometimes you can only reproduce a crash with an optimized build, but the -g flag always remains useful in this regard (and objcopy can strip those symbols for general distribution.) I'm guessing the above was built with '-g' but with some '-O', optimizing out some of the args that might have been helpful. Since we can't see above which command in your command_rec array caused this segfault, we can see you had an invalid string element. Line 546 of config.c tripped over your input. config.c:546 was trying to; dir = apr_pstrdup(tpool, cmd->name); This suggests you added a command to the list without an actual char* string name value. Compare your command_rec list with the templates of the various AP_INIT_* macros to ensure you provided valid initializers... only static const array values. Ensure you NULL terminate that list.