url_title(): Argument #1 ($str) must be of type string, null given, called in C:\xamppp\htdocs\codeigniter4\app\Controllers\Komik.php on line 57 - codeigniter

url_title(): Argument #1 ($str) must be of type string, null given, called in C:\xamppp\htdocs\codeigniter4\app\Controllers\Komik.php on line 57
url_title(): Argument #1 ($str) must be of type string, null given, called in C:\xamppp\htdocs\codeigniter4\app\Controllers\Komik.php on line 57

Related

Problem in running spring-boot application in debug mode: Thread [main] (Suspended (exception ClassNotFoundException))

I am using Spring Tool Suite 4-4.8.1. The program runs perfectly while running as spring boot app but when running the app in debug mode, the process suspends. It automatically opens Class.class file. The following information is shown under debug tab:
Margin_Lending_Web - MarginLendingWebApplication [Spring Boot App]
com.margin_lending.MarginLendingWebApplication at localhost:55672
Thread [main] (Suspended (exception ClassNotFoundException))
owns: RMIConnectorServer (id=29)
owns: Class<T> (sun.management.jmxremote.ConnectorBootstrap) (id=27)
Class<T>.forName0(String, boolean, ClassLoader, Class<?>) line: not available [native method]
Class<T>.forName(String, boolean, ClassLoader) line: 468
Util.createSkeleton(Remote) line: 332
UnicastServerRef.setSkeleton(Remote) line: 256
UnicastServerRef.exportObject(Remote, Object, boolean) line: 229
ConnectorBootstrap$PermanentExporter.exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory, ObjectInputFilter) line: 205
RMIJRMPServerImpl.export(Remote, ObjectInputFilter) line: 153
RMIJRMPServerImpl.export() line: 138
RMIConnectorServer.start() line: 453
ConnectorBootstrap.exportMBeanServer(MBeanServer, int, int, boolean, boolean, String, String[], String[], boolean, boolean, String, String, boolean, String, String, String) line: 840
ConnectorBootstrap.startRemoteConnectorServer(String, Properties) line: 481
Agent.startAgent(Properties) line: 447
Agent.startAgent() line: 599
D:\sts-4.8.1.RELEASE\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_15.0.0.v20201014-1246\jre\bin\javaw.exe (Jan 26, 2023, 8:42:25 PM)
I tried to clean and update the project, but the problem persists.

Does the args command in Delve also show the return value (and not just the function arguments)?

During reverse engineering a Golang binary using Delve I was inspecting the full stack in which frame 0 belonged to the Go function strings.genSplit:
(dlv) stack -full
0 0x00000000004a4278 in strings.genSplit
at /usr/lib/go/src/strings/strings.go:266
s = "my_string" my comment: actual string modified but not the rest of the variables
sep = ","
sepSave = 0
n = 11
~r4 = (unreadable empty OP stack)
a = []string len: 12, cap: 12, [...]
i = (unreadable could not find loclist entry at 0x9d89c for address 0x4a4278)
m = (unreadable could not find loclist entry at 0x9da7d for address 0x4a4278)
Now if you look at the documentation for strings.genSplit here, you can see that s, sep, sepSave, and n are the actual (input) arguments while a, i, and m are the local variables of the function. Also
(dlv) goroutine 22 frame 0 locals
a = []string len: 12, cap: 12, [...]
i = (unreadable could not find loclist entry at 0x9d89c for address 0x4a4278)
m = (unreadable could not find loclist entry at 0x9da7d for address 0x4a4278)
and
(dlv) goroutine 22 frame 0 args
s = "my_string" my comment: actual string modified but not the rest of the variables
sep = ","
sepSave = 0
n = 11
~r4 = (unreadable empty OP stack)
My questions are 1. Is Delve including the return value with the actual function arguments (i.e., inputs)? 2. What do the ~ sign and 4 in ~r4 mean?
trying to answer both your questions in one step.
In go function arguments and results are allocated in the stack on function call, so the return variables are allocated as soon as you call the function.
If you use named return values, delve will show you the variable name, otherwise it will use the internal representation that will start at 0 for the first argument and go on through the return values.
In the case you mention you have 4 arguments that would be r0-r3 and one unnamed return that is r4. The ~ sign denotes an unnamed value and I've only seen it used to also represent ~panic.

Discriminated union type checking in F# with differernt return types

I am trying to write an interpreter in F#. I want to check the type of expressions.
Here is my discriminated union for the expressions
type Expr =
| Integer of int
| String of string
| Boolean of bool
This is the method i am using to check the types with
let checkType (e:Expr) =
match e with
| String s -> s
| Integer i -> i
| Boolean b -> b
I want the method to determine wether an expression is a string,integer or boolean.
However, visual studio gives me the following error on line 4 of the checkType method:
This expression was expected to have type string but here has type int
Am i missing something?
To expand on John Palmer's comment:
F# expects each function to have a single return type. For example, you can write a function that takes an int and returns an int, which would be a function of type int -> int. A function that parses strings into ints would be of type string -> int. And so on.
Now, what is the return type of the checkType function you've written? Since you don't specify a return type, the compiler looks at the type of the values you can return from the function -- every possible code branch must return a value, and they must all be the same type. So it looks at your match statement, sees that its first branch returns a string, and says, "Ah ha! I've figured out the return type of this function; this is a function that takes an Expr and returns a string. The function's type is Expr -> string."
Then it looks at the second branch of your match statement, and says, "Wait a minute. This is a function that returns a string, but in this code branch it's returning an int. That's not valid: the code that calls this function needs to know what type to expect it to return." And so you get the error.
Now, if you were to swap the order of your match statement cases, checking for Integer i first, then the compiler would evaluate your function as having type Expr -> int (taking an Expr input and returning an int output), and throw an error on the | String s -> s line. This time, the error would be "Wait a minute, this is a function that returns an int, so the expression s here should have been of type int. But instead, it's of type string. That's not valid."
Or delete the | String s -> s line, and you'll see an error "This expression was expected to have type int but here has type bool." Same thing: each function can have only one return type. If you want to return multiple different possible types from a function, that's what Discriminated Unions are for.
For more reading on F# types, see http://fsharpforfunandprofit.com/series/understanding-fsharp-types.html.
You can wrap all of the expressions into an Option type like Some or String:
let checkType (e:Expr) =
match e with
| String e -> "we are string: " + string e
| Integer e-> "we are integer: " + string e
| Boolean e -> "we are boolean: " + string e

Efficient string concatenation in Scala

The JVM optimzes String concatenation with + and replaces it with a StringBuilder. This should be the same in Scala. But what happens if strings are concatenated with ++=?
var x = "x"
x ++= "y"
x ++= "z"
As far as I know this methods treats strings like char seqences, so even if the JVM would create a StringBuilder it would lead to many method calls, right? Would it be better to use a StringBuilder instead?
To what type is the String converted implicitly?
There is a huge HUGE difference in time taken.
If you add strings repeatedly using += you do not optimize away the O(n^2) cost of creating incrementally longer strings. So for adding one or two you won't see a difference, but it doesn't scale; by the time you get to adding 100 (short) strings, using a StringBuilder is over 20x faster. (Precise data: 1.3 us vs. 27.1 us to add the string representations of the numbers 0 to 100; timings should be reproducible to about += 5% and of course are for my machine.)
Using ++= on a var String is far far worse yet, because you are then instructing Scala to treat a string as a character-by-character collection which then requires all sorts of wrappers to make the String look like a collection (including boxed character-by-character addition using the generic version of ++!). Now you're 16x slower again on 100 additions! (Precise data: 428.8 us for ++= on a var string instead of +='s 26.7 us.)
If you write a single statement with a bunch of +es then the Scala compiler will use a StringBuilder and end up with an efficient result (Data: 1.8 us on non-constant strings pulled out of an array).
So, if you add strings with anything other than + in line, and you care about efficiency, use a StringBuilder. Definitely don't use ++= to add another String to a var String; there just isn't any reason to do it, and there's a big runtime penalty.
(Note--very often you don't care at all how efficient your string additions are! Don't clutter your code with extra StringBuilders unless you have reason to suspect that this particular code path is getting called a lot.)
Actually, the inconvenient truth is StringOps usually remains an allocation:
scala> :pa
// Entering paste mode (ctrl-D to finish)
class Concat {
var x = "x"
x ++= "y"
x ++= "z"
}
// Exiting paste mode, now interpreting.
defined class Concat
scala> :javap -prv Concat
Binary file Concat contains $line3.$read$$iw$$iw$Concat
Size 1211 bytes
MD5 checksum 1900522728cbb0ed0b1d3f8b962667ad
Compiled from "<console>"
public class $line3.$read$$iw$$iw$Concat
SourceFile: "<console>"
[snip]
public $line3.$read$$iw$$iw$Concat();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=6, locals=1, args_size=1
0: aload_0
1: invokespecial #19 // Method java/lang/Object."<init>":()V
4: aload_0
5: ldc #20 // String x
7: putfield #10 // Field x:Ljava/lang/String;
10: aload_0
11: new #22 // class scala/collection/immutable/StringOps
14: dup
15: getstatic #28 // Field scala/Predef$.MODULE$:Lscala/Predef$;
18: aload_0
19: invokevirtual #30 // Method x:()Ljava/lang/String;
22: invokevirtual #34 // Method scala/Predef$.augmentString:(Ljava/lang/String;)Ljava/lang/String;
25: invokespecial #36 // Method scala/collection/immutable/StringOps."<init>":(Ljava/lang/String;)V
28: new #22 // class scala/collection/immutable/StringOps
31: dup
32: getstatic #28 // Field scala/Predef$.MODULE$:Lscala/Predef$;
35: ldc #38 // String y
37: invokevirtual #34 // Method scala/Predef$.augmentString:(Ljava/lang/String;)Ljava/lang/String;
40: invokespecial #36 // Method scala/collection/immutable/StringOps."<init>":(Ljava/lang/String;)V
43: getstatic #28 // Field scala/Predef$.MODULE$:Lscala/Predef$;
46: invokevirtual #42 // Method scala/Predef$.StringCanBuildFrom:()Lscala/collection/generic/CanBuildFrom;
49: invokevirtual #46 // Method scala/collection/immutable/StringOps.$plus$plus:(Lscala/collection/GenTraversableOnce;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object;
52: checkcast #48 // class java/lang/String
55: invokevirtual #50 // Method x_$eq:(Ljava/lang/String;)V
See more demonstration at this answer.
Edit: To say more, you're building the String on each reassignment, so, no you're not using a single StringBuilder.
However, the optimization is done by javac and not the JIT compiler, so to compare fruits of the same kind:
public class Strcat {
public String strcat(String s) {
String t = " hi ";
String u = " by ";
return s + t + u; // OK
}
public String strcat2(String s) {
String t = s + " hi ";
String u = t + " by ";
return u; // bad
}
}
whereas
$ scala
Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_11).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :se -Xprint:typer
scala> class K { def f(s: String, t: String, u: String) = s ++ t ++ u }
[[syntax trees at end of typer]] // <console>
def f(s: String, t: String, u: String): String = scala.this.Predef.augmentString(scala.this.Predef.augmentString(s).++[Char, String](scala.this.Predef.augmentString(t))(scala.this.Predef.StringCanBuildFrom)).++[Char, String](scala.this.Predef.augmentString(u))(scala.this.Predef.StringCanBuildFrom)
is bad. Or, worse, to unroll Rex's explanation:
"abc" ++ "def"
augmentString("abc").++[Char, String](augmentString("def"))(StringCanBuildFrom)
collection.mutable.StringBuilder.newBuilder ++= new WrappedString(augmentString("def"))
val b = collection.mutable.StringBuilder.newBuilder
new WrappedString(augmentString("def")) foreach b.+=
As Rex explained, StringBuilder overrides ++=(String) but not Growable.++=(Traversable[Char]).
In case you've ever wondered what unaugmentString is for:
28: invokevirtual #40 // Method scala/Predef$.augmentString:(Ljava/lang/String;)Ljava/lang/String;
31: invokevirtual #43 // Method scala/Predef$.unaugmentString:(Ljava/lang/String;)Ljava/lang/String;
34: invokespecial #46 // Method scala/collection/immutable/WrappedString."<init>":(Ljava/lang/String;)V
And just to show that you do finally call unadorned +=(Char) but after boxing and unboxing:
public final scala.collection.mutable.StringBuilder apply(char);
flags: ACC_PUBLIC, ACC_FINAL
Code:
stack=2, locals=2, args_size=2
0: aload_0
1: getfield #19 // Field b$1:Lscala/collection/mutable/StringBuilder;
4: iload_1
5: invokevirtual #24 // Method scala/collection/mutable/StringBuilder.$plus$eq:(C)Lscala/collection/mutable/StringBuilder;
8: areturn
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this L$line10/$read$$iw$$iw$$anonfun$1;
0 9 1 x C
LineNumberTable:
line 9: 0
public final java.lang.Object apply(java.lang.Object);
flags: ACC_PUBLIC, ACC_FINAL, ACC_BRIDGE, ACC_SYNTHETIC
Code:
stack=2, locals=2, args_size=2
0: aload_0
1: aload_1
2: invokestatic #35 // Method scala/runtime/BoxesRunTime.unboxToChar:(Ljava/lang/Object;)C
5: invokevirtual #37 // Method apply:(C)Lscala/collection/mutable/StringBuilder;
8: areturn
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this L$line10/$read$$iw$$iw$$anonfun$1;
0 9 1 v1 Ljava/lang/Object;
LineNumberTable:
line 9: 0
A good laugh does get some oxygen into the bloodstream.

how to dump string using Windbg poi function

Debugging .Net String value in windbg and WinDbg and SoS, how do I print/dump a large string? show a script that dump the string to a local file:
$$ Dumps the managed strings to a file
$$ Platform x86
$$ Usage $$>a<"c:\temp\dumpstringtofolder.txt" 6544f9ac 5000 c:\temp\stringtest
$$ First argument is the string method table pointer
$$ Second argument is the Min size of the string that needs to be used filter the strings
$$ Third is the path of the file
.foreach ($string {!dumpheap -short -mt ${$arg1} -min ${$arg2}})
{
$$ MT Field Offset Type VT Attr Value Name
$$ 65452978 40000ed 4 System.Int32 1 instance 71117 m_stringLength
$$ 65451dc8 40000ee 8 System.Char 1 instance 3c m_firstChar
$$ 6544f9ac 40000ef 8 System.String 0 shared static Empty
$$ start of string is stored in the 8th offset, which can be inferred from above
$$ Size of the string which is stored in the 4th offset
r#$t0= poi(${$string}+4)*2
.writemem ${$arg3}${$string}.txt ${$string}+8 ${$string}+8+#$t0
}
this script is on x86. I modify the code and try on .net 4.0, x64 system.
the only difference is that the offset is different. for example:
$$ .net 4.0 , the offset is different
$$ MT Field Offset Type VT Attr Value Name
$$ 000007fee4abc7e8 4000103 8 System.Int32 1 instance 460 m_stringLength
$$ 000007fee4abb328 4000104 c System.Char 1 instance 26 m_firstChar
$$ 000007fee4ab6900 4000105 10 System.String 0 shared static Empty
So, I change my code to:
r#$t0= poi(${$string}+8)*2
.writemem ${$arg3}${$string}.txt ${$string}+c ${$string}+c+#$t0
Here, I wonder the function poi,
1. why here need '*2'?
2. I find a string address, run !do, like this:
0:000> !do 0x00000000ffad0de0
Name: System.String
MethodTable: 000007fef5da6738
EEClass: 000007fef592ed68
Size: 794(0x31a) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String: jv15Rr2HXPn3....
Fields:
MT Field Offset Type VT Attr Value Name
000007fef5dac620 4000103 8 System.Int32 1 instance 384 m_stringLength
000007fef5dab160 4000104 c System.Char 1 instance 6a m_firstChar
000007fef5da6738 4000105 10 System.String 0 shared static Empty
I run
0:000> ? poi(0x00000000ffad0de0)+8
Evaluate expression: 8791627818816 = 000007fe`f5da6740
to get the length value of 384, but the output value is wrong(displayed is 8791627818816).
What is wrong?
Thank you for helping me!
updated 1):
I tried:
0:000> r#$t0= poi(0x00000000ffad0de0+8)
0:000> r#$t0
$t0=0076006a00000180
the result seems not correct.
Update 2):
I tried to debug the script:
.echo ${$str}
r#$t0= poi(${$str}+8)*2
.printf "#$t0 is %d\n", #$t0
.echo ${$arg3}${$str}.txt
.printf "${$str}+c: %p\n", ${$str}+c
.printf "${$str}+c+#$t0: %p\n", ${$str}+c+#$t0
$$.writemem ${$arg3}${$str}.txt ${$str}+c ${$str}+c+#$t0
then I got the output:
0x00000000ffad4550
#$t0 is 640
c:\stringtest\0x00000000ffad4550.txt
0x00000000ffad4550+c: 00000000ffad455c
0x00000000ffad4550+c+#$t0: 00ec00d4ffad47dc
then I run the .writemem for the output address:
0:000> .writemem c:\stringtest\ss.txt 00000000ffad455c L0n640
Writing 280 bytes.
I got the correct string, it's like this:
/txrqcf...........j7ULyzqxSmB3bpu
I run the command:
0:000> .writemem c:\stringtest\ss.txt 00000000ffad455c 00ec00d4ffad47dc
^ Range error
I got the error Range error, I check the link to find out the result, but I have no idea.
poi(${$string}+8) is the string length in characters.
*2 is needed because Strings in C# are Unicode and for writing memory, we need the bytes, not characters.
+c is the offset of the char[] on 64 bit. That's the start address to write from.
? poi(0x00000000ffad0de0)+8
This is incorrect, because poi(0x00000000ffad0de0) gives you the value of the method table of the .NET object, which is 000007fef5da6738 and then you add 8, which is 7FEF5DA6740.
What you want to do is
? poi(0x00000000ffad0de0+8)
inside the braces.
To bypass the range error, use the L? syntax instead range start and range end:
.writemem ${$arg3}${$str}.txt ${$str}+c L? #$t0

Resources